import decimal

line = input()

a,b,k,c = (line.split(" "))

if c != a and c != b:
    print("0")
    exit(0)

xD = decimal.Decimal(2)
kD = decimal.Decimal(k)

cont = decimal.Context()
res = cont.multiply(cont.power(xD, kD, 1000000007), kD)

if a != b:
    res = cont.divide(res, 2)

_, resF = cont.divmod(res, 1000000007)
print(resF)
exit(0)
