local mfl = math.floor local function bmulalt(x, y, mod) local x1, y1 = x % 10000, y % 10000 local x2, y2 = mfl(x / 10000) % 10000, mfl(y / 10000) % 10000 local x3, y3 = mfl(x / 100000000), mfl(y / 100000000) local ret = (x1 * y1 + (x1 * y2 + x2 * y1) * 10000) % mod ret = (ret + (x1 * y3 + x2 * y2 + x3 * y1) * 10000 % mod * 10000 % mod) % mod ret = (ret + (x2 * y3 + x3 * y2) * 10000 % mod * 10000 % mod * 10000) % mod ret = (ret + x3 * y3 * 10000 % mod * 10000 % mod * 10000 % mod * 10000) % mod return ret end local function modpow(src, pow, mod) local res = 1 while 0 < pow do if pow % 2 == 1 then res = bmulalt(res, src, mod) pow = pow - 1 end src = bmulalt(src, src, mod) pow = mfl(pow / 2) end return res end local a, b, c = io.read("*n", "*n", "*n") a = bmulalt(a, b, 1000000007) a = bmulalt(a, c, 1000000007) local k = io.read("*n") local r = modpow(2, k, 1000000007 - 1) print(modpow(a, r, 1000000007))