eolymp
bolt
Try our new interface for solving problems
Problems

Archer`s Travel

Archer`s Travel

Let an archer be a chessman that can move one square forward, back, to the left, or to the right. An archer is situated at the square (1, 1) of an n × m chessboard (the upper right square of the board is coded as (n, m)). The archer's goal is to travel through the board and return to the initial position in such a way that each square of the board is visited exactly once (the travel starts with the first move of the archer). It is required to determine the number of different ways to perform such a travel.

Input

Two positive integers n and m (2n5, 2m < 109).

Output

Print the number of ways to travel through the board calculated modulo 109.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2 3
Output example #1
2
Source 2006 Ural SU Contest, Petrozavodsk Winter Session, January, Problem A