// Arup Guha
// 2/21/2012
// Solution to 2011 Mercer Problem 10: Odd Matrices

import java.util.*;
import java.math.*;

public class prob10 {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int N = stdin.nextInt();
		int M = stdin.nextInt();

		// Go through each case.
		while (N!=0 && M!=0) {

			// Parity argument fails here. No solution.
			if (N%2 != M%2)
				System.out.println("0");
				
			// We're free to fill in all but the last row and column, which will be dictated
			// completely by what we fill in previous. So the answer is 2^((n-1)(m-1)) mod
			// 10^9.
			else {
				int product = (N - 1)*(M - 1);
				BigInteger billion = new BigInteger("1000000000");
				BigInteger x = new BigInteger( (new Integer(product)).toString() );
				BigInteger two = new BigInteger("2");
				BigInteger answer = two.modPow(x, billion);
				System.out.println(answer);
			}

			N = stdin.nextInt();
			M = stdin.nextInt();
		}
	}
}