Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to k, where k is either 1 or -1.

Now Ralph wants you to figure out the number of ways to put numbers in each block in such a way that the magic field works properly. Two ways are considered different if and only if there exists at least one block where the numbers in the first way and in the second way are different. You are asked to output the answer modulo 1000000007 = 10^9 + 7.

Note that there is no range of the numbers to put in the blocks, but we can prove that the answer is not infinity.


-----Input-----

The only line contains three integers n, m and k (1 ≤ n, m ≤ 10^18, k is either 1 or -1).


-----Output-----

Print a single number denoting the answer modulo 1000000007.


-----Examples-----
Input
1 1 -1

Output
1

Input
1 3 1

Output
1

Input
3 3 -1

Output
16



-----Note-----

In the first example the only way is to put -1 into the only block.

In the second example the only way is to put 1 into every block.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Number theory

Combinatorics

Mathematics

Constructive algorithms


Solutions:
(n, m, k) = map(int, input().split())
mod = int(1000000000.0 + 7)

def pow(a, n):
	res = 1
	while n:
		if n & 1:
			res = res * a % mod
		n //= 2
		a = a * a % mod
	return res
if k == -1 and (n + m) % 2 == 1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1)))


def fast_p(x, y, mod):
	if y == 0:
		return 1
	if y % 2:
		return x * fast_p(x, y - 1, mod) % mod
	else:
		t = fast_p(x, y // 2, mod)
		return t * t % mod

def main():
	(n, m, k) = map(int, input().split())
	if (n + m) % 2 and k == -1:
		print(0)
		return
	y = (n - 1) * (m - 1)
	t1 = fast_p(2, n - 1, 1000000007)
	print(fast_p(t1, m - 1, 1000000007))
main()


(n, m, k) = [int(x) for x in input().split()]
if k == -1 and (n + m) % 2 == 1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), 1000000007))


def fastpow(base, exp, mod):
	res = 1
	while exp > 0:
		if exp % 2 == 1:
			res = res * base % mod
		base = base * base % mod
		exp //= 2
	return res % mod
(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
ans = fastpow(2, (a - 1) * (b - 1), 1000000007)
if (a + b) % 2 == 1:
	if c == -1:
		ans = 0
print(ans)


(a, b, c) = list(map(int, input().split()))
if c == -1 and (a + b) % 2 != 0:
	print(0)
else:
	print(pow(2, a * b - a - b + 1, 1000000007))


(n, m, k) = list(map(int, input().split()))

def st(n, x=2):
	if n == 1:
		return x
	if n == 0:
		return 1
	s = st(n // 2, x)
	return s * s % 1000000007 * st(n % 2, x) % 1000000007
if k == 1:
	ans = st(n - 1, st(m - 1))
	print(ans % 1000000007)
elif (n + m) % 2 == 0:
	ans = st(n - 1, st(m - 1))
	print(ans % 1000000007)
else:
	print(0)


def pow(x, n):
	res = 1
	while n:
		if n & 1:
			res = res * x % 1000000007
		n >>= 1
		x = x * x % 1000000007
	return res
(n, m, k) = map(int, input().split())
if (n + m) % 2 and k == -1:
	print(0)
else:
	(n, m) = (n - 1, m - 1)
	print(pow(pow(2, n), m))


import sys
arr = [int(x) for x in input().split()]
n = arr[0]
m = arr[1]
k = arr[2]
if n % 2 != m % 2 and k == -1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), 1000 * 1000 * 1000 + 7))


(n, m, k) = [int(i) for i in input().split()]
(n, m) = (min(n, m), max(n, m))
mod = 1000000007

def f_pow(a, k):
	if k == 0:
		return 1
	if k % 2 == 1:
		return f_pow(a, k - 1) * a % mod
	else:
		return f_pow(a * a % mod, k // 2) % mod
if k == -1:
	if n % 2 == 0 and m % 2 == 1 or (n % 2 == 1 and m % 2 == 0):
		print(0)
	else:
		print(f_pow(2, (n - 1) * (m - 1) % (mod - 1)) % mod)
else:
	print(f_pow(2, (n - 1) * (m - 1) % (mod - 1)) % mod)


(n, m, k) = list(map(int, input().split()))
if (n + m) % 2 == 1 and k == -1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), 10 ** 9 + 7))


def bin_exp(x, n, m):
	r = 1
	while n > 0:
		if n % 2 == 1:
			r = r * x % m
		x = x * x % m
		n = n // 2
	return r
M = 1000000007
I = [int(i) for i in input().split()]
n = I[0]
m = I[1]
k = I[2]
if n % 2 != m % 2 and k == -1:
	print(0)
else:
	h = bin_exp(2, n - 1, M)
	h = bin_exp(h, m - 1, M)
	print(h)


p = 10 ** 9 + 7
s = input()
(n, m, k) = tuple((int(x) for x in s.split()))
if k == -1 and (n + m) % 2 == 1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), p))


mod = int(1000000000.0 + 7)
line = input().split()
(n, m, k) = (int(line[0]), int(line[1]), int(line[2]))
if n % 2 != m % 2 and k == -1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1) % (mod - 1), mod))


MOD = 1000000007

def calc(n, m, k):
	if k == -1 and n % 2 != m % 2:
		return 0
	n = n - 1
	m = m - 1
	n = n * m
	r = 1
	s = 2
	while n > 0:
		if n % 2 == 1:
			r = r * s % MOD
		n //= 2
		s = s * s % MOD
	return r
(n, m, k) = input().split(' ')
print(calc(int(n), int(m), int(k)))


(n, m, k) = map(int, input().split())
if k == -1 and n - m & 1:
	print(0)
else:
	s = (n - 1) * (m - 1)
	t = 2
	ans = 1
	while s > 0:
		if s & 1:
			ans = ans * t % (10 ** 9 + 7)
		t = t * t % (10 ** 9 + 7)
		s //= 2
	print(ans)


def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
a = list(map(int, input().split()))
n = a[0]
m = a[1]
k = a[2]
if k == -1 and (n % 2 == 0 and m % 2 != 0 or (n % 2 != 0 and m % 2 == 0)):
	print(0)
else:
	print(power(2, (n - 1) * (m - 1), 10 ** 9 + 7))


def pwr(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
(n, m, k) = map(int, input().split())
hell = 1000000007
if n % 2 and (m - 1) % 2 or (m % 2 and (n - 1) % 2):
	if k == -1:
		print(0)
		exit(0)
ans1 = pwr(2, n - 1, hell) % hell
print(pwr(ans1 % hell, m - 1, hell) % hell)


(n, m, k) = map(int, input().split())
if k == -1 and (n - m) % 2 != 0:
	print(0)
elif n * m - n - m + 1 <= 0:
	print(1)
else:
	print(pow(2, n * m - n - m + 1, 1000000007))


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	(n, m, k) = read()
	if n % 2 != m % 2 and k < 0:
		print(0)
		return
	else:
		print(power(2, (m - 1) * (n - 1), MOD))
for _ in range(1):
	solve()


(n, m, k) = map(int, input().split())
if k == -1 and (n % 2 == 0 and m % 2 != 0 or (n % 2 != 0 and m % 2 == 0)):
	print(0)
else:
	ans = pow(2, (n - 1) * (m - 1), 1000000007)
	print(ans)


def mod_pow(val, p, MOD):
	if p == 0:
		return 1
	if p == 1:
		return val
	res = mod_pow(val, p >> 1, MOD)
	res = res * res
	res %= MOD
	if p % 2:
		res = val * res % MOD
	return res
(n, m, k) = [int(i) for i in input().split()]
if k == -1 and n % 2 != m % 2:
	print(0)
else:
	print(mod_pow(2, (n - 1) * (m - 1), 1000000007))


MOD = 10 ** 9 + 7

def fast_pow(k):
	product = 1
	base = 2
	while k:
		if k & 1:
			product *= base
			product %= MOD
		base *= base
		base %= MOD
		k //= 2
	return product
s = input()
s = s.split()
N = int(s[0])
M = int(s[1])
K = int(s[2])
if N + M & 1 and K == -1:
	print(0)
else:
	print(fast_pow((N - 1) * (M - 1)))


(n, m, k) = [int(x) for x in input().split()]
md = 1000000007

def pw(p):
	p %= md - 1
	r = 1
	cp = 2
	while p > 0:
		if p % 2 == 1:
			r = r * cp % md
		p //= 2
		cp *= cp
		cp %= md
	return r
if n % 2 != m % 2 and k == -1:
	print(0)
else:
	print(pw((n - 1) * (m - 1)))


import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2
prime = [True for i in range(10)]
pp = [0] * 10

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p * p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				pp[i] += 1
				prime[i] = False
		p += 1

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[n - 1]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] >= key:
			res = arr[mid]
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[0]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = arr[mid]
			left = mid + 1
	return res
t = 1
for _ in range(t):
	(n, m, k) = map(int, input().split())
	if k == -1 and n % 2 != m % 2:
		print(0)
	else:
		print(pow(2, (n - 1) * (m - 1), mod))


def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
(n, m, k) = map(int, input().split())
if n % 2 == 0 and k == -1 and (m % 2 != 0):
	print('0')
elif n % 2 != 0 and k == -1 and (m % 2 == 0):
	print('0')
else:
	print(power(2, (m - 1) * (n - 1), 1000000007))


(n, m, t) = map(int, input().split())
if t == -1 and m % 2 != n % 2:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), 1000000007))


def pow(n, m):
	p = m
	x = n
	res = 1
	while p:
		if p % 2 == 1:
			res = res * x % 1000000007
			p -= 1
		x = x * x % 1000000007
		p = p // 2
	return res
(n, m, k) = map(int, input().split())
if k == -1:
	if n % 2 == 0 and m % 2 == 1 or (n % 2 == 1 and m % 2 == 0):
		print('0')
		exit()
ans = pow(2, m - 1) % 1000000007
print(pow(ans, n - 1) % 1000000007)


import math
(m, n, k) = map(int, input().split())
x = 10 ** 9 + 7
if m % 2 != n % 2 and k == -1:
	print(0)
else:
	print(pow(2, m * n - m - n + 1, x))


def main():

	def binpow(a, n):
		res = 1
		while n:
			if n % 2:
				res = res * a % mod
			a = a * a % mod
			n //= 2
		return res
	read = lambda : tuple(map(int, input().split()))
	mod = 1000000007

	def mul(a, b):
		v = a * b
		return v - mod if v > mod else v
	(m, n, k) = read()
	if m > n:
		(m, n) = (n, m)
	a = m + n - 1
	m -= 1
	d = m * (m + 1)
	c = a * m - d
	if 2 * m > a:
		c += 1
	if (m + n) % 2 == 0 and k == -1:
		print(0)
	elif c <= 0 or m == 0:
		print(1)
	else:
		print(binpow(2, c))
main()


def check(a):
	global ans
	arr = []
	for i in range(len(a)):
		if i % m == 0:
			arr.append([])
		arr[-1].append(a[i])
	for i in range(n):
		c = 1
		for j in range(m):
			c *= arr[i][j]
		if c != k:
			return
	for j in range(m):
		c = 1
		for i in range(n):
			c *= arr[i][j]
		if c != k:
			return
	ans += 1

def f(a, cur):
	if cur == n * m:
		check(a)
		return
	a[cur] = 1
	f(a, cur + 1)
	a[cur] = -1
	f(a, cur + 1)

def pereb(n, m, k):
	arr = [0 for i in range(n * m)]
	f(arr, 0)
(n, m, k) = map(int, input().split())
if k == -1 and (n + m) % 2 == 1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), 10 ** 9 + 7))


import sys, queue, string, math, itertools
try:
	import dev_act_ffc429465ab634
	DEV = True
except:
	DEV = False

def log(*s):
	if DEV:
		print('LOG', *s)

class EJudge:

	def __init__(self, problem='default', reclim=1 << 30):
		self.problem = problem
		sys.setrecursionlimit(reclim)

	def use_files(self, infile='', outfile=''):
		if infile != '':
			self.infile = open(infile)
			sys.stdin = self.infile
		if infile != '':
			self.outfile = open(outfile, 'w')
			sys.stdout = self.outfile

	def use_bacs_files(self):
		self.use_files(self.problem + '.in', self.problem + '.out')

	def get_tl(self):
		while True:
			pass

	def get_ml(self):
		tmp = [[[5] * 100000 for _ in range(1000)]]
		while True:
			tmp.append([[5] * 100000 for _ in range(1000)])

	def get_re(self):
		s = (0,)[8]

	def get_wa(self, wstr='blablalblah'):
		for _ in range(3):
			print(wstr)
		exit()

class IntReader:

	def __init__(self):
		self.ost = queue.Queue()

	def get(self):
		return int(self.sget())

	def sget(self):
		if self.ost.empty():
			for el in input().split():
				self.ost.put(el)
		return self.ost.get()

	def release(self):
		res = []
		while not self.ost.empty():
			res.append(self.ost.get())
		return res
ej = EJudge('')
int_reader = IntReader()
fmap = lambda f, *l: list(map(f, *l))
parse_int = lambda : fmap(int, input().split())
revrange = lambda x: range(x - 1, -1, -1)

def aeq(ar, v):
	for el in ar:
		if el != v:
			return False
	return True
k = -1
(h, w) = (5, 1)

def calcfast(h, w, k):
	if k == -1 and h + w & 1:
		return 0
	ans = pow(2, (h - 1) * (w - 1), 1000000007)
	return ans

def calc(h, w, k):
	a = [[0] * w for i in range(h)]
	ans = 0
	for mask in range(2 ** (h * w)):
		cur_mask = mask
		for pos in range(h * w):
			a[pos // w][pos % w] = 1 if cur_mask & 1 == 1 else -1
			cur_mask >>= 1
		(rowsum, colsum) = ([1] * h, [1] * w)
		for i in range(h):
			for j in range(w):
				rowsum[i] *= a[i][j]
				colsum[j] *= a[i][j]
		if aeq(rowsum, k) and aeq(colsum, k):
			ans += 1
	print('calced for ', h, w, k, '=', ans)
	return ans
(h, w, k) = parse_int()
print(calcfast(h, w, k) % 1000000007)


def pow2(p):
	r = 1
	c = 2
	while p != 0:
		if p & 1:
			r *= c
		c *= c
		r %= 10 ** 9 + 7
		c %= 10 ** 9 + 7
		p >>= 1
	return r
(n, m, k) = map(int, input().split())
if n < m:
	(n, m) = (m, n)
if k == -1 and (m + n) % 2:
	print(0)
else:
	print(pow2((n - 1) * (m - 1)))


def f(b, e, m):
	result = 1
	while e != 0:
		if e & 1 == 1:
			result = result * b % m
		e >>= 1
		b = b * b % m
	return result
a = [int(i) for i in input().split()]
(n, m, k) = (a[0], a[1], a[2])
if k == -1:
	if (n + m) % 2 == 1:
		print(0)
	elif n == 1 or m == 1:
		print(1)
	else:
		print(f(2, n * m - n - m + 1, 1000000007))
elif k == 1:
	if n == 1 or m == 1:
		print(1)
	else:
		print(f(2, n * m - n - m + 1, 1000000007))


(n, m, k) = [int(z) for z in input().split()]
kek = n % 2
if m % 2 != kek and k == -1:
	print(0)
	exit(0)
tmp = pow(2, n - 1, 1000000007)
ans = pow(tmp, m - 1, 1000000007)
print(ans)


mod = 1000000007

def BinPow2(x, n):
	if n == 0:
		return 1
	if n % 2 == 0:
		return BinPow2(x * x % mod, n // 2) % mod
	else:
		return x * (BinPow2(x * x % mod, (n - 1) // 2) % mod) % mod
(n, m, k) = list(map(int, input().split()))
if k == -1 and n % 2 != m % 2:
	print(0)
else:
	print(BinPow2(2, (n - 1) * (m - 1)))


(n, m, k) = map(int, input().split())
print([pow(2, (n - 1) * (m - 1), 10 ** 9 + 7), 0][k + (n + m) % 2 == 0])


c = 10 ** 9 + 7
(n, m, k) = map(int, input().split())
t = (m - 1) * (n - 1)
s = 2
if k == -1 and (m - n) % 2 == 1:
	print(0)
else:
	l = []
	while t > 0:
		l.append(t % 2)
		t //= 2
	if l == []:
		print(1)
	else:
		l.pop()
		while l != []:
			y = l.pop()
			s = s ** 2 * 2 ** y % c
		print(s)


mod = 1000000007

def pow(n):
	if n == 0:
		return 1
	if n == 1:
		return 2
	if n % 2 == 1:
		return pow(n // 2) ** 2 * 2 % mod
	else:
		return pow(n // 2) ** 2 % mod
(n, m, k) = map(int, input().split())
if (n % 2 + m % 2) % 2 == 1 and k == -1:
	print(0)
	exit()
if n == 1 or m == 1:
	print(1)
else:
	print(pow((n - 1) * (m - 1)))


import math
(n, m, k) = map(lambda x: int(x), input().split())
x = 2
res = 1
temp = (n - 1) * (m - 1)
while temp > 0:
	b = divmod(temp, 2)[1]
	if b == 1:
		res *= x
		temp -= 1
	else:
		x *= x
		temp = divmod(temp, 2)[0]
	x = divmod(x, 1000000007)[1]
	res = divmod(res, 1000000007)[1]
if divmod(n, 2)[1] != divmod(m, 2)[1] and k == -1:
	res = 0
print(res)


p = 10 ** 9 + 7

def pow_(x):
	res = 1
	exp = 2
	while x:
		if x % 2:
			res = res * exp % p
		exp = exp * exp % p
		x //= 2
	return res
s = input()
(n, m, k) = tuple((int(x) for x in s.split()))
if k == -1 and (n + m) % 2 == 1:
	print(0)
else:
	print(pow_((n - 1) * (m - 1)))


mod = 1000000007

def sqr(n):
	return n * n % mod

def pow(a, n):
	if n == 0:
		return 1
	if n % 2 == 1:
		return sqr(pow(a, n >> 1)) * a % mod
	return sqr(pow(a, n >> 1))
(n, m, k) = list(map(int, input().split()))
if (n + m) % 2 == 1 and k == -1:
	print(0)
	return
print(pow(2, (n - 1) * (m - 1)))


mod = int(1000000000.0 + 7)

def pot2(n):
	if n == 0:
		return 1
	mit = pot2(n >> 1)
	if n & 1 == 1:
		return mit * mit * 2 % mod
	return mit * mit % mod

def main():
	(a, b, c) = [int(x) for x in input().split()]
	if c == -1 and b % 2 != a % 2:
		print(0)
		return
	print(pot2((a - 1) * (b - 1)))
main()


(n, m, k) = list(map(int, input().split()))
MOD = 1000000007

def inv(a, m):
	return pow(a, m - 2, m)

def pow(base, power, MOD):
	result = 1
	while power > 0:
		if power % 2 == 1:
			result = result * base % MOD
		power = power // 2
		base = base * base % MOD
	return result
if k == -1 and n % 2 != m % 2:
	print(0)
elif min(n, m) == 1:
	print(1)
else:
	ans = pow(2, (n - 1) * (m - 1), MOD)
	print(ans)


a = [int(i) for i in input().split()]
n = a[0]
m = a[1]
k = a[2]

def b(y, p):
	if y * y == y:
		return 1
	if p == 0:
		return 1
	i = 1
	x = y
	while x < 1000000007:
		i *= 2
		x = x * x
	x = x % 1000000007
	return b(x, p // i) * (pow(y, p % i) % 1000000007) % 1000000007
if k == -1 and (n + m) % 2 == 1:
	print(0)
else:
	print(b(2, (n - 1) % 1000000006 * ((m - 1) % 1000000006) % 1000000006))


a = [int(x) for x in input().split()]
if a[2] == -1 and (a[0] + a[1]) % 2 == 1:
	print(0)
else:
	print(pow(2, (a[0] - 1) * (a[1] - 1), 1000000007))


from sys import stdin, stdout
(m, n, k) = [int(x) for x in stdin.readline().rstrip().split()]
large_prime = 10 ** 9 + 7

def fastPower(base, exp, mod):
	if exp == 0:
		x = 1
	else:
		half = fastPower(base, exp // 2, mod)
		x = half * half
		if exp % 2 == 1:
			x *= base
	return x % mod

def solve_two(n, m, k):
	if (m + n) % 2 == 1 and k == -1:
		print(0)
		return
	power1 = (m - 1) % (large_prime - 1)
	power2 = (n - 1) % (large_prime - 1)
	print(fastPower(2, power1 * power2, large_prime))
	return
solve_two(m, n, k)


import sys

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
(n, m, k) = mi()
if k == -1:
	if n % 2 != m % 2:
		print(0)
		sys.exit(0)
x = (n - 1) * (m - 1)
d = pow(2, x, 1000000007)
print(d)


def even(a):
	return a % 2 == 0

def solve(n, m, k):
	if k == -1:
		if int(even(n)) + int(even(m)) == 1:
			print(0)
			return
	print(pow(2, (n - 1) * (m - 1), 1000000007))
solve(*[int(i) for i in input().split()])


mod = int(1000000000.0 + 7)

def power(n, k):
	r = 1
	while k != 0:
		if k % 2 != 0:
			r = r * n % mod
			k -= 1
		else:
			n = n * n % mod
			k = k // 2
	return r
(n, m, k) = map(int, input().split())
if k == -1 and (m + n) % 2 != 0:
	print(0)
else:
	print(power(power(2, m - 1), n - 1))


(n, m, k) = [int(x) for x in input().split()]
if n % 2 != m % 2 and k != 1:
	print(0)
else:
	mod = 10 ** 9 + 7
	pow1 = (n - 1) * (m - 1) % (mod - 1)
	print(pow(2, pow1, mod))


def mod_pow(a, b, m):
	if b == 0:
		return 1
	if b == 1:
		return a % m
	tmp = mod_pow(a, b // 2, m)
	tmp = tmp * tmp % m
	if b % 2 == 1:
		tmp = tmp * a % m
	return tmp
mod = 1000000006
(n, m, res) = map(int, input().split())
if m % 2 != n % 2 and res == -1:
	print(0)
else:
	k = (m - 1) % mod * ((n - 1) % mod) % mod
	ans = mod_pow(2, k, mod + 1)
	print(ans)


(n, m, k) = map(int, input().split())
MOD = 1000000007

def modpow(n, r):
	global MOD
	if r == 0:
		return 1
	rtn = modpow(n, r // 2)
	rtn *= rtn
	rtn %= MOD
	if r % 2 == 1:
		rtn *= n
		rtn %= MOD
	return rtn
ans = 1
if n == 1 or m == 1:
	if k == -1:
		ans = n % 2 * (m % 2)
elif k == -1 and n % 2 != m % 2:
	ans = 0
else:
	ans = modpow(2, (n - 1) % (MOD - 1) * ((m - 1) % (MOD - 1)) % (MOD - 1))
print(ans)


mod = 1000000007
(n, m, k) = map(int, input().split())
if k == -1 and (n + m) % 2 == 1:
	print(0)
else:
	print(pow(pow(2, min(n, m) - 1, mod), max(n, m) - 1, mod))


(n, m, k) = map(int, input().split())
p = (n - 1) * (m - 1)
if k < 0 and n % 2 != m % 2:
	r = 0
else:
	r = pow(2, p, 1000000007)
print(r)


def pow(x, p):
	if p == 0:
		return 1
	if p % 2 == 0:
		return pow(x * x % mod, p // 2)
	return x * pow(x, p - 1) % mod
(n, m, k) = list(map(int, input().split()))
mod = 1000000007
if k == 1:
	if n == 1 or m == 1:
		print(1)
	else:
		print(pow(2, (n - 1) * (m - 1)))
elif n % 2 != m % 2:
	print(0)
elif n == 1 or m == 1:
	print(1)
else:
	print(pow(2, (n - 1) * (m - 1)))


A = input().split()
n = int(A[0])
m = int(A[1])
k = int(A[2])

def ans(e):
	final = 1
	for i in range(0, e):
		final = final * 2 % 1000000007
	return final
if m == 1:
	if k == 1:
		print(1)
	elif k == -1:
		if n % 2 == 0:
			print(0)
		elif n % 2 == 1:
			print(1)
elif n == 1:
	if k == 1:
		print(1)
	elif k == -1:
		if m % 2 == 0:
			print(0)
		elif m % 2 == 1:
			print(1)
elif k == 1:
	e1 = (m - 1) % 1000000006
	e2 = (n - 1) % 1000000006
	e = e1 * e2 % 1000000006
	print(pow(2, e, 1000000007))
elif k == -1:
	if m % 2 != n % 2:
		print(0)
	else:
		e1 = (m - 1) % 1000000006
		e2 = (n - 1) % 1000000006
		e = e1 * e2 % 1000000006
		print(pow(2, e, 1000000007))


from math import *
(n, m, k) = map(int, input().split(' '))
ans = 2 ** ((n - 1) * (m - 1) % 1000000006) % 1000000007
if k == -1:
	if (n + m) % 2 == 1:
		ans = 0
print(ans)


(n, m, k) = map(int, input().split())
if k == -1 and n % 2 ^ m % 2 == 1:
	print(0)
	exit()
MOD = 10 ** 9 + 7
print(pow(2, (n - 1) * (m - 1), MOD))


prime_modulo = 1000000007

def gett_pow(pow_num):
	if pow_num == 1:
		return 2
	if pow_num == 0:
		return 1
	if pow_num % 2 == 0:
		return gett_pow(pow_num // 2) ** 2 % prime_modulo
	else:
		return 2 * gett_pow(pow_num // 2) ** 2 % prime_modulo
params = [int(x) for x in input().strip().split()]
if params[0] > params[1]:
	(params[0], params[1]) = (params[1], params[0])
if (params[0] == 1 and params[1] % 2 == 0 or params[0] % 2 != params[1] % 2) and params[2] == -1:
	print('0')
else:
	print(str(gett_pow((params[0] - 1) * (params[1] - 1))))


(n, m, k) = list(map(int, input().split()))
mod = 10 ** 9 + 7

def p(x):
	if x == 0:
		return 1
	if x % 2 == 0:
		return p(x // 2) ** 2 % mod
	return p(x // 2) ** 2 * 2 % mod
if k == -1 and (n + m) % 2 == 1:
	print(0)
else:
	print(p(n * m - n - m + 1))


import math
(n, m, k) = map(int, input().split())
if k == 1 or (n + m) % 2 == 0:
	print(pow(2, (n - 1) * (m - 1), 1000000007))
else:
	print('0')


mod = 1000000007
(n, m, k) = list(map(int, input().split()))
if k == -1:
	co = n + m
	if co % 2 != 0:
		print('0')
	else:
		n = n - 1
		m = m - 1
		n = n * m
		co = pow(2, n, mod)
		co %= 1000000007
		print(co)
else:
	n = n - 1
	m = m - 1
	n = n * m
	co = pow(2, n, mod)
	co %= 1000000007
	print(co)


def fast_pow(x, y):
	if y == 0:
		return 1
	p = fast_pow(x, y // 2)
	p = p * p % 1000000007
	if y % 2:
		p = p * x % 1000000007
	return p
(n, m, k) = list(map(int, input().split()))
if n == 1 or m == 1:
	if k == 1:
		print(1)
	elif n * m == 1:
		print(1)
	else:
		print(0)
elif k == 1 or (m + n) % 2 == 0:
	print(fast_pow(2, (n - 1) * (m - 1)))
else:
	print(0)


(r, c, tipo) = input('').split()
r = int(r)
c = int(c)
tipo = int(tipo)
base = pow(2, r - 1, 1000000007)
ans = pow(base, c - 1, 1000000007)
if tipo == -1 and r % 2 != c % 2:
	print('0')
else:
	print(ans)


(n, m, k) = map(int, input().split())
if n % 2 != m % 2 and k == -1:
	print(0)
	exit()
print(pow(2, (n - 1) * (m - 1), 1000000007))


s = input().strip().split()
(a, b, c) = tuple(map(int, s))
re = 1
mod = int(1000000000.0 + 7)
p = (a - 1) * (b - 1)
base = 2
while p != 0:
	if p % 2 == 1:
		re *= base
	base *= base
	base %= mod
	re %= mod
	p >>= 1
if c == -1 and a % 2 != b % 2:
	print(0)
else:
	print(re)


import sys
import math
from collections import defaultdict, deque
import heapq
(n, m, k) = map(int, sys.stdin.readline().split())
mod = 10 ** 9 + 7
ans = pow(2, (n - 1) * (m - 1), mod)
if m % 2 != 0 and n % 2 == 0 and (k == -1):
	ans = 0
if m % 2 == 0 and n % 2 != 0 and (k == -1):
	ans = 0
print(ans)


ins = [int(x) for x in input().split(' ')]
n = ins[0]
m = ins[1]
k = ins[2]
big = 1000000007
if n == 1:
	if k == 1:
		print('1')
	if k == -1:
		if m % 2 == 1:
			print('1')
		else:
			print('0')
elif m == 1:
	if k == 1:
		print('1')
	if k == -1:
		if n % 2 == 1:
			print('1')
		else:
			print('0')
elif k == -1:
	if n % 2 != m % 2:
		print('0')
	else:
		print(pow(2, (n - 1) * (m - 1), big))
else:
	print(pow(2, (n - 1) * (m - 1), big))


a = [int(x) for x in input().split()]
n = a[0]
m = a[1]
k = a[2]
if (n + m) % 2 == 1 and k == -1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), int(1000000000.0 + 7)))


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
mod = 10 ** 9 + 7
if k == -1 and n % 2 != m % 2:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), mod))


x = input().split()
n = int(x[0])
m = int(x[1])
k = int(x[2])
tmp = (n - 1) * (m - 1)
odds = 1
ans = 2
if tmp == 0:
	ans = 1
while tmp > 1:
	if tmp % 2 == 1:
		odds = odds * ans % 1000000007
		ans = ans * ans % 1000000007
		tmp = tmp // 2
	else:
		ans = ans * ans % 1000000007
		tmp = tmp // 2
	ans = ans % 1000000007
ans = ans * odds % 1000000007
if k == -1:
	if n % 2 != m % 2:
		ans = 0
print(ans)


def main():
	read = lambda : tuple(map(int, input().split()))
	mod = 1000000007
	(m, n, k) = read()
	if m > n:
		(m, n) = (n, m)
	a = m + n - 1
	m -= 1
	d = m * (m + 1)
	c = a * m - d
	if 2 * m > a:
		c += 1
	if (m + n) % 2 == 0 and k == -1:
		print(0)
	elif c <= 0 or m == 0:
		print(1)
	else:
		print(pow(2, c, mod))
main()


n = 1000000000 + 7
(a, b, c) = map(int, input().split())
if c == -1 and (b % 2 == 0 and a % 2 == 1 or (b % 2 == 1 and a % 2 == 0)):
	print('0')
else:
	print(pow(2, (a - 1) * (b - 1), n))


def binpow(x, y):
	if y == 0:
		return 1
	elif y & 1 == 0:
		g = binpow(x, y >> 1) % 1000000007
		return g * g % 1000000007
	else:
		g = binpow(x, y >> 1) % 1000000007
		return g * g * x % 1000000007
(n, m, k) = map(int, input().split())
d = (n - 1) * (m - 1)
ans = 0 if k == -1 and n + m & 1 == 1 else binpow(2, d)
print(ans)


s = input()
(a, b, c) = s.split(' ')
a = int(a)
b = int(b)
c = int(c)

def fast_pow(x, y):
	if y == 0:
		return 1
	if y % 2 == 1:
		return fast_pow(x, y - 1) * x % 1000000007
	else:
		b = fast_pow(x, y // 2) % 1000000007
		return b * b % 1000000007
if (a + b) % 2 == 1 and c == -1:
	print(0)
else:
	print(fast_pow(2, (b - 1) * (a - 1)) % 1000000007)


def main():
	(N, M, K) = [int(i) for i in input().split()]
	if (N + M) % 2 != 0 and K == -1:
		print(0)
	else:
		P = (N - 1) * (M - 1)
		print(pow(2, P, 1000000007))
main()


(n, m, k) = map(int, input().split())
nm = n + m
if nm & 1 and k == -1:
	print(0)
else:
	ans = 1
	base = 2
	p = (n - 1) * (m - 1)
	mod = 1000000007
	while p:
		if p & 1:
			ans = ans * base % mod
		base = base * base % mod
		p = p >> 1
	print(ans)


import sys

def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	while b != 0:
		temp = a % b
		a = b
		b = temp
	return a
a = [0 for i in range(10000)]
a[0] = 2
for i in range(1, 10000):
	a[i] = a[i - 1] * a[i - 1] % 1000000007
while True:
	(m, n, k) = map(int, input().split())
	exp = (m - 1) * (n - 1)
	if k == -1:
		if m % 2 * (n % 2) == 0:
			if (m + n) % 2 == 1:
				print(0)
				break
	if exp == 0:
		print(1)
		break
	ans = 1
	for i in range(10000):
		if exp == 0:
			break
		if exp % 2 == 1:
			ans = ans * a[i] % 1000000007
		exp = exp // 2
	print(ans % 1000000007)
	break


(x, y, z) = map(int, input().split())
if (x - y) % 2 == 1 and z == -1:
	print(0)
else:
	print(pow(2, x * y - x - y + 1, 1000000007))


a = input().split(' ')
n = int(a[0])
m = int(a[1])
k = int(a[2])
if k is -1:
	if (n + m) % 2 is 1:
		print(0)
	elif n is 1:
		print(1)
	elif m is 1:
		print(1)
	else:
		x = m + n - 1
		n = x
		n += 1
		n -= 2
		m -= 1
		print(pow(2, (n - m) * m, 1000000007))
else:
	x = m + n - 1
	n = x
	n += 1
	n -= 2
	m -= 1
	print(pow(2, (n - m) * m, 1000000007))


(n, m, k) = input().split(' ')
n = int(n)
m = int(m)
k = int(k)
if k == -1 and (m + n) % 2:
	print(0)
else:
	mod = 1000000007
	print(pow(pow(2, n - 1, mod), m - 1, mod))


(n, m, k) = map(int, input().split())

def pow(a, p):
	mod = 10 ** 9 + 7
	if not p:
		return 1
	if p % 2:
		return a % mod * (pow(a, p // 2) % mod) ** 2 % mod
	return (pow(a, p // 2) % mod) ** 2 % mod
mod = 10 ** 9 + 7
print(0 if n % 2 != m % 2 and k == -1 else pow(pow(2, n - 1), m - 1))


import sys
[n, m, k] = sys.stdin.readline().split()
n = int(n)
m = int(m)
k = int(k)

def iseven(x):
	if x % 2 == 0:
		return True
	return False
if iseven(n + m) == False and k == -1:
	print(0)
else:
	print(pow(2, (n - 1) * (m - 1), 10 ** 9 + 7))


def fast_pow(a, b):
	if a == 0:
		return 1
	val1 = fast_pow(a // 2, b)
	if a % 2:
		return val1 * val1 % 1000000007 * b % 1000000007
	return val1 * val1 % 1000000007
(n, m, k) = map(int, input().split())
if (n + m) % 2 and k == -1:
	print(0)
	exit()
print(fast_pow((n - 1) * (m - 1), 2))


MODULO = 1000000007

def pow(x):
	result = 1
	value = 2
	while x > 0:
		if x % 2 == 1:
			result = result * value % MODULO
		value = value ** 2 % MODULO
		x = x // 2
	return result

def task(n, m, k):
	if k == -1 and n % 2 != m % 2:
		return 0
	if n == 1 or m == 1:
		return 1
	return pow((n - 1) * (m - 1))

def main():
	(n, m, k) = map(int, input().split(' '))
	print(task(n, m, k))

def test():
	import doctest
	doctest.testmod()
main()


mo = 1000000007

def fast_pow(p):
	if p == 0:
		return 1
	if p % 2 == 1:
		return 2 * (fast_pow(p // 2) ** 2 % mo)
	return fast_pow(p // 2) ** 2 % mo
arr = input().split(' ')
n = int(arr[0])
m = int(arr[1])
k = int(arr[2])
if (n + m) % 2 == 1 and k == -1:
	print('0')
else:
	print(fast_pow((n - 1) * (m - 1)) % mo)


(n, m, k) = map(int, input().split())
print(0 if n + m & 1 and k < 0 else pow(2, (n - 1) * (m - 1), int(1000000000.0 + 7)))


def fastExpMod(b, e, m):
	result = 1
	while e != 0:
		if e & 1 == 1:
			result = result * b % m
		e >>= 1
		b = b * b % m
	return result
n = 1000000000 + 7
(a, b, c) = map(int, input().split())
if c == -1 and (b % 2 == 0 and a % 2 == 1 or (b % 2 == 1 and a % 2 == 0)):
	print('0')
else:
	print(fastExpMod(2, (a - 1) * (b - 1), n))


(n, m, k) = map(int, input().split())
if k == -1 and n & 1 ^ m & 1:
	print('0')
else:

	def pow1(a, b, n):
		result = 0
		x = a
		while b:
			if b & 1:
				result = result * a % n
			x = x * x % n
			b = b << 1
		return result
	a = pow(2, (n - 1) * (m - 1), 1000000007)
	print(a)


from sys import stdin, stdout
from random import randrange
MOD = 10 ** 9 + 7

def stress(n, m):
	previous = [0 for i in range(n)]
	for z in range(sze):
		for i in range(n):
			for j in range(previous[i], 2 ** m):
				previous

def power(n, x):
	ans = 1
	while n:
		if n & 1:
			ans = ans * x % MOD
		n >>= 1
		x = x * x % MOD
	return ans

def solution():
	(n, m, k) = map(int, stdin.readline().split())
	if n & 1 and (not m & 1) and (k == -1):
		stdout.write('0')
		return
	if m & 1 and (not n & 1) and (k == -1):
		stdout.write('0')
		return
	stdout.write(str(power((n - 1) * (m - 1), 2)))
solution()


(n, m, k) = [int(i) for i in input().split()]
if (n + m) % 2 == 1 and k == -1:
	print(0)
	exit(0)
result = 1
power = (n - 1) * (m - 1)
print(pow(2, power, 1000000007))


(n, m, k) = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def pow(a, b, mod):
	ret = 1
	while b > 0:
		if b % 2 == 1:
			ret = a * ret % mod
		a = a * a % mod
		b //= 2
	return ret
if n & 1 != m & 1 and k == -1:
	print(0)
	exit(0)
else:
	print(pow(2, (n - 1) * (m - 1), MOD))


(n, m, k) = map(int, input().split())
mod = int(1000000000.0 + 7)
if (n % 2 == 0 and m % 2 or (n % 2 and m % 2 == 0)) and k == -1:
	print(0)
	exit(0)

def binpowmod(a, n):
	if n == 0:
		return 1
	if n % 2:
		return binpowmod(a, n - 1) * a % mod
	else:
		b = binpowmod(a, n // 2)
		return b * b % mod
print(binpowmod(2, (m - 1) * (n - 1)))


(r, c, k) = [int(i) for i in input().split()]
if r % 2 == 1 - c % 2 and k == -1:
	print(0)
elif r != 1 and c != 1:
	print(pow(2, r * c - r - c + 1, 1000000007))
elif r == 1 or c == 1:
	print(1)


(n, m, k) = map(int, input().split())

def pow(n):
	global mod
	x = 2
	ans = 1
	while n:
		if n & 1:
			ans = ans * x % mod
		x = x * x % mod
		n >>= 1
	return ans
mod = 10 ** 9 + 7
if k == -1 and n % 2 != m % 2:
	print(0)
else:
	print(pow((n - 1) * (m - 1) % (mod - 1)))


def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
MOD = 10 ** 9 + 7
[n, m, k] = list_input()

def pow2(k):
	if k == 0:
		return 1
	res = pow2(k // 2)
	res = res * res % MOD
	if k % 2 == 1:
		res = res * 2 % MOD
	return res
if n % 2 != m % 2 and k == -1:
	print(0)
	exit(0)
print(pow2((n - 1) * (m - 1)))


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
MOD = 1000000007
(N, M, K) = map(int, input().split())

def my_pow_2(x):
	if x == 0:
		return 1
	h = my_pow_2(x // 2)
	if x & 1:
		return h * h * 2 % MOD
	else:
		return h * h % MOD
if K == -1 and N % 2 != M % 2:
	print(0)
else:
	print(my_pow_2((N - 1) * (M - 1)))


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
if (a - b) % 2 == 1 and c == -1:
	print(0)
else:
	print(pow(2, (a - 1) * (b - 1), int(1000000000.0 + 7)))


MOD = 1000000007
(N, M, K) = map(int, input().split())
if K == -1 and N % 2 != M % 2:
	print('0')
	exit(0)
POW = N * M - (N + M - 1)
print(pow(int(2), int(POW), int(MOD)))


MODULO = 1000000007

def fast_pow(x):
	if x == 1:
		return 2
	if x == 0:
		return 1
	prev = fast_pow(x // 2)
	add = 1 if x % 2 == 0 else 2
	return prev * prev * add % MODULO
(n, m, k) = map(int, input().split())
if k == -1 and n % 2 != m % 2:
	print(0)
else:
	print(fast_pow(n * m - n - m + 1))


(n, m, k) = map(int, input().split())
a = (n - 1) * (m - 1)
z = 2
if a == 0:
	z = 1
zd = 1
mod = 1000000007
while a > 1:
	if a % 2 == 1:
		zd = zd * z % mod
	z = z * z % mod
	a = a // 2
z = z * zd % mod
if k == -1:
	if n % 2 == m % 2:
		print(z)
	else:
		print(0)
else:
	print(z)


(a, b, c) = [int(i) for i in input().split(' ')]

def exp_mod_prime(x, p):
	x = x % (p - 1)
	a = 2
	bonus = 1
	while x > 1:
		if x % 2 == 1:
			bonus = bonus * a % p
		a = a * a % p
		x = x // 2
	return a * bonus % p
if c == 1:
	if a == 1:
		result = 1
	elif b == 1:
		result = 1
	else:
		result = exp_mod_prime((a - 1) * (b - 1), 1000000007)
elif a == 1:
	if b % 2 == 0:
		result = 0
	else:
		result = 1
elif b == 1:
	if a % 2 == 0:
		result = 0
	else:
		result = 1
elif (a + b) % 2 == 1:
	result = 0
else:
	result = exp_mod_prime((a - 1) * (b - 1), 1000000007)
print(result % 1000000007)


(m, n, k) = map(int, input().split())
mod = 10 ** 9 + 7

def powermod(x, y):
	res = 1
	while y > 0:
		if y & 1:
			res = res * x % mod
		x = x * x % mod
		y = y >> 1
	return res
if m % 2 != n % 2 and k == -1:
	print(0)
else:
	print(powermod(2, (m - 1) * (n - 1)))


MOD = 1000000007

def fast_exp(x, y):
	if y == 0:
		return 1
	ans = fast_exp(x, y // 2)
	ans = ans * ans % MOD
	if y % 2 != 0:
		ans = ans * x % MOD
	return ans
(n, m, k) = [int(x) for x in input().split()]
if k == 1:
	print(fast_exp(2, n * m - n - m + 1))
elif n % 2 == m % 2:
	print(fast_exp(2, n * m - n - m + 1))
else:
	print(0)


A = list(map(int, input().split()))
x = A[0]
y = A[1]
k = A[2]
if (x + y) % 2 == 1 and k == -1:
	print('0')
else:
	if x > y:
		z = x
		x = y
		y = z
	if x == 1:
		print('1')
	else:
		start = (x - 1) * (x - 1)
		dif = y - x
		start = start + dif * (x - 1)
		p = 1000000007
		res = 1
		x = 2
		y = start
		while y > 0:
			if y % 2 == 1:
				res = res * x % p
			y = y // 2
			x = x * x % p
		print(res)


def pow_h(base, degree, module=int(1000000000.0 + 7)):
	degree = bin(degree)[2:]
	r = 1
	for i in range(len(degree) - 1, -1, -1):
		r = r * base ** int(degree[i]) % module
		base = base ** 2 % module
	return r
(n, m, k) = map(int, input().split())
if n > m:
	(n, m) = (m, n)
if k == -1 and m % 2 != n % 2:
	print(0)
else:
	print(pow_h(2, (n - 1) * (m - 1)) % int(1000000000.0 + 7))