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.

Difficulty: interview

Starter code:

Solutions:
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), 10**9 + 7))

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))


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)))

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")
else:
    if 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))


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



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)
else:
    if 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))

# IAWT
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))


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

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)



def fastExpMod(b, e, m):
    result = 1
    while e != 0:
        if (e&1) == 1:
            # ei = 1, then mul
            result = (result * b) % m
        e >>= 1
        # b, b^2, b^4, b^8, ... , b^(2^n)
        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))

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

if n%2 != m%2 and k == -1:
    print(0)
else:
    ret = pow(2, (n-1)*(m-1), 10**9+7)
    print(ret)

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)

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))

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)))
else:
    if n % 2 != m % 2:
        print(0)
    elif n == 1 or m == 1:
        print(1)
    else:
        print(pow(2, (n - 1) * (m - 1)))


def f(b, e, m):
    result = 1
    while e != 0:
        if (e&1) == 1:
            # ei = 1, then mul
            result = (result * b) % m
        e >>= 1
        # b, b^2, b^4, b^8, ... , b^(2^n)
        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)
    else:
        if 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 = 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 )

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)                               
else:
    print(f_pow(2, (n - 1) * (m -1)) % mod)


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)
else:
    if 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)


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)))


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))

"""
ATSTNG's ejudge Python3 solution template
(actual solution is below)
"""

import sys, queue, string, math, itertools

try:
    import dev_act_ffc429465ab634  # empty file in directory
    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)
        return

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: list(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)):
        #print(bin(mask)[2:])
        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(rowsum, colsum)

    print('calced for ', h,w,k, '=',ans)
    return ans


'''
for h in range(2, 3):
    for w in range(1, 20):
        for k in [1, -1]:
            ans = calc(h, w, k)
            print('OK' if ans == calcfast(h,w,k) else "ERROR")
'''

h,w,k = parse_int()
print(calcfast(h,w,k)%1000000007)
#'''









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))

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 )

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)