typedef long long ll; typedef long double ld; #include using namespace std; #define int long long // modint struct Fp { // static menber static int MOD; // inner value long long val; // constructor Fp() : val(0) { } Fp(long long v) : val(v % MOD) { if (val < 0) val += MOD; } long long get() const { return val; } static int get_mod() { return MOD; } static void set_mod(int mod) { MOD = mod; } // arithmetic operators Fp operator - () const { return val ? MOD - val : 0; } Fp operator + (const Fp &r) const { return Fp(*this) += r; } Fp operator - (const Fp &r) const { return Fp(*this) -= r; } Fp operator * (const Fp &r) const { return Fp(*this) *= r; } Fp operator / (const Fp &r) const { return Fp(*this) /= r; } Fp& operator += (const Fp &r) { val += r.val; if (val >= MOD) val -= MOD; return *this; } Fp& operator -= (const Fp &r) { val -= r.val; if (val < 0) val += MOD; return *this; } Fp& operator *= (const Fp &r) { val = val * r.val % MOD; return *this; } Fp& operator /= (const Fp &r) { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b, swap(a, b); u -= t * v, swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } Fp pow(long long n) const { Fp res(1), mul(*this); while (n > 0) { if (n & 1) res *= mul; mul *= mul; n >>= 1; } return res; } Fp inv() const { Fp res(1), div(*this); return res / div; } // other operators bool operator == (const Fp &r) const { return this->val == r.val; } bool operator != (const Fp &r) const { return this->val != r.val; } friend istream& operator >> (istream &is, Fp &x) { is >> x.val; x.val %= x.get_mod(); if (x.val < 0) x.val += x.get_mod(); return is; } friend ostream& operator << (ostream &os, const Fp &x) { return os << x.val; } friend Fp modpow(const Fp &r, long long n) { return r.pow(n); } friend Fp modinv(const Fp &r) { return r.inv(); } }; int Fp::MOD; // Union-Find struct UnionFind { // core member vector par; // constructor UnionFind() { } UnionFind(int n) : par(n, -1) { } void init(int n) { par.assign(n, -1); } // core methods int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool same(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x), y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } // debug friend ostream& operator << (ostream &s, UnionFind uf) { map> groups; for (int i = 0; i < uf.par.size(); ++i) { int r = uf.root(i); groups[r].push_back(i); } for (const auto &it : groups) { s << "group: "; for (auto v : it.second) s << v << " "; s << endl; } return s; } }; // matrix template struct Matrix { vector > val; Matrix(int n = 1, int m = 1, T v = 0) : val(n, vector(m, v)) {} void init(int n, int m, T v = 0) {val.assign(n, vector(m, v));} void resize(int n, int m) { val.resize(n); for (int i = 0; i < n; ++i) val[i].resize(m); } Matrix& operator = (const Matrix &A) { val = A.val; return *this; } size_t size() const {return val.size();} vector& operator [] (int i) {return val[i];} const vector& operator [] (int i) const {return val[i];} friend ostream& operator << (ostream& s, const Matrix& M) { s << endl; for (int i = 0; i < (int)M.size(); ++i) s << M[i] << endl; return s; } }; template Matrix operator * (const Matrix &A, const Matrix &B) { Matrix R(A.size(), B[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < B[0].size(); ++j) for (int k = 0; k < B.size(); ++k) R[i][j] += A[i][k] * B[k][j]; return R; } template Matrix pow(const Matrix &A, long long n) { Matrix R(A.size(), A.size()); auto B = A; for (int i = 0; i < A.size(); ++i) R[i][i] = 1; while (n > 0) { if (n & 1) R = R * B; B = B * B; n >>= 1; } return R; } template vector operator * (const Matrix &A, const vector &B) { vector v(A.size()); for (int i = 0; i < A.size(); ++i) for (int k = 0; k < B.size(); ++k) v[i] += A[i][k] * B[k]; return v; } template Matrix operator + (const Matrix &A, const Matrix &B) { Matrix R(A.size(), A[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < A[0].size(); ++j) R[i][j] = A[i][j] + B[i][j]; return R; } template Matrix operator - (const Matrix &A, const Matrix &B) { Matrix R(A.size(), A[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < A[0].size(); ++j) R[i][j] = A[i][j] - B[i][j]; return R; } signed main(){ Matrix a(2, 2, 0); std::cin >> a[0][0]>>a[0][1]; std::cin >> a[1][0]>>a[1][1]; auto b = a*a*a; std::cout << b[0][0]<<" "<