#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; #include using mint = atcoder::modint1000000007; int main() { cin.tie(nullptr)->sync_with_stdio(false); ll a, b, c, d, n; cin >> a >> b >> c >> d >> n; mint ans = mint(16).pow(n / 8); n %= 8; ll maxim = -1e18; for (ll _x : { a, b }) { for (ll _y : { c, d }) { ll x = _x, y = _y; rep(_, n) { ll xx = x - y, yy = x + y; swap(x, xx), swap(y, yy); } maxim = max(maxim, x + y); } } ans *= maxim; cout << ans.val() << '\n'; return 0; }