#include using namespace std; // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") // using namespace __gnu_pbds; // #include // using Bint = boost::multiprecision::cpp_int; // #include // using namespace atcoder; // https://atcoder.github.io/ac-library/production/document_ja/ using uint = unsigned int; using ll = long long; using ull = unsigned long long; using ld = long double; constexpr ll mod = 1e9+7; constexpr ll INF = 9'223'372'036'854'775'807/10; #define rep(i,n) for (uint i = 0; i < uint(n); ++i) #define All(a) (a).begin(),(a).end() #define PI acos(-1) vector dx = {1, 0, -1, 0, 1, 1, -1, -1}; vector dy = {0, 1, 0, -1, 1, -1, 1, -1}; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b(const Edge &e) const { return cost > e.cost; } friend ostream& operator<<(ostream& os, const Edge& e) { os << e.from << " " << e.to << " (" << e.cost << ")"; return os; } }; struct Graph { vector> G; vector edges; int idx = 0; Graph() {} Graph(uint n) : G(n) {} void add_edge_direct(uint from, uint to, ll cost = 1) { G[from].emplace_back(from, to, cost, idx); edges.emplace_back(from, to, cost, idx); idx++; } void add_edge(uint from, uint to, ll cost = 1) { G[from].emplace_back(from, to, cost, idx); G[to].emplace_back(to, from, cost, idx); edges.emplace_back(from, to, cost, idx); idx++; } size_t size() const { return G.size(); } vector& operator[](int k) { return G[k]; } friend ostream& operator<<(ostream& os, Graph& g) { for (uint i = 0; i < g.size(); i++) { for (Edge e : g[i]) { cout << e << '\n'; } } return os; } }; struct IoSetup { IoSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << setprecision(15) << fixed; } } iosetup; void print(const vector &v) { for (string s : v) { cout << s << '\n'; } } template void print(const vector> &v, uint w = 0) { for (uint i = 0; i < (uint)v.size(); i++) { cout << right << setw(w) << v[i].first << ' ' << v[i].second << '\n'; } } template void print(const vector &v, uint w = 0) { for (uint i = 0; i < (uint)v.size(); i++) { cout << right << setw(w) << v[i] << " \n"[i == (int)v.size() - 1]; } } template void print(const vector> &v, uint w = 0) { for (uint i = 0; i < (uint)v.size(); i++) { print(v[i], w); } } template void print(const T& arg) { cout << arg << '\n'; } template void print(const T& arg, const Args&... args) { cout << arg << ' '; print(args...); } template istream& operator>>(istream& is, vector& vec) { for (auto& x : vec) is >> x; return is; } template struct Matrix { int cols, rows; vector> mat; Matrix(int n, int m) : cols(m), rows(n), mat(n, vector(m)) {} Matrix(int n) : cols(n), rows(n), mat(n, vector(n)) {} Matrix(vector> &v) : mat(v) { rows = mat.size(); cols = mat[0].size(); } Matrix(vector &v) : mat(v, 1) { rows = mat.size(); cols = mat[0].size(); } Matrix(initializer_list> v) : mat(v) { rows = mat.size(); cols = mat[0].size(); } // 要素アクセス vector& operator[](int i) { return mat[i]; } T& operator()(int i, int j) { return mat[i][j]; } // 単位行列 Matrix eye(int n) { Matrix res(n); for (int i = 0; i < n; i++) { res.mat[i][i] = 1; } return res; } // 足し算 Matrix operator+(const Matrix& rhs) const { assert(rows == rhs.rows && cols == rhs.cols); Matrix res(rows, cols); for (int i = 0; i < rows; i++) { for (int j = 0;j < cols; j++) { res.mat[i][j] = mat[i][j] + rhs.mat[i][j]; } } return res; } // 足し算の代入 Matrix& operator+=(const Matrix& rhs) { assert(rows == rhs.rows && cols == rhs.cols); for (int i = 0; i < rows; i++) { for (int j = 0;j < cols; j++) { mat[i][j] += rhs.mat[i][j]; } } return *this; } // 引き算 Matrix operator-(const Matrix& rhs) const { assert(rows == rhs.rows && cols == rhs.cols); Matrix res(rows, cols); for (int i = 0; i < rows; i++) { for (int j = 0;j < cols; j++) { res.mat[i][j] = mat[i][j] - rhs.mat[i][j]; } } return res; } // 引き算の代入 Matrix& operator-=(const Matrix& rhs) { assert(rows == rhs.rows && cols == rhs.cols); for (int i = 0; i < rows; i++) { for (int j = 0;j < cols; j++) { mat[i][j] -= rhs.mat[i][j]; } } return *this; } // 掛け算 Matrix operator*(const Matrix& rhs) const { assert(cols == rhs.rows); Matrix res(rows, rhs.cols); for (int i = 0; i < rows; i++) { for (int j = 0; j < rhs.cols; j++) { for (int k = 0; k < cols; k++) { res.mat[i][j] += mat[i][k] * rhs.mat[k][j]; } } } return res; } // 掛け算の代入 Matrix& operator*=(const Matrix& rhs) { assert(cols == rhs.rows); Matrix res(rows, rhs.cols); for (int i = 0; i < rows; i++) { for (int j = 0; j < rhs.cols; j++) { for (int k = 0; k < cols; k++) { res.mat[i][j] += mat[i][k] * rhs.mat[k][j]; } } } *this = res; return *this; } // スカラー倍 Matrix operator*(const long long& rhs) const { Matrix res(rows, cols); for (int i = 0; i < rows; i++) { for (int j = 0;j < cols; j++) { res.mat[i][j] = mat[i][j] * rhs; } } return res; } // スカラー倍の代入 Matrix& operator*=(const long long& rhs) { for (int i = 0; i < rows; i++) { for (int j = 0;j < cols; j++) { mat[i][j] *= rhs; } } return *this; } // スカラー逆数倍 Matrix operator/(const long long& rhs) const { Matrix res(rows, cols); for (int i = 0; i < rows; i++) { for (int j = 0;j < cols; j++) { res.mat[i][j] = mat[i][j] / rhs; } } return res; } // スカラー逆数倍の代入 Matrix& operator/=(const long long& rhs) { for (int i = 0; i < rows; i++) { for (int j = 0;j < cols; j++) { mat[i][j] /= rhs; } } return *this; } // 転置 Matrix transpose() const { Matrix res(cols, rows); for (int i = 0; i < cols; i++) { for (int j = 0;j < rows; j++) { res.mat[i][j] = mat[j][i]; } } return res; } // 内積 long long dot(const Matrix& rhs) const { assert(rows == 1 && rhs.rows == 1 && cols == rhs.cols); long long res = 0; for (int i = 0; i < cols; i++) { res += mat[0][i] * rhs.mat[0][i]; } return res; } long long dot(const vector& rhs) const { assert(rows == 1 && cols == rhs.size()); long long res = 0; for (int i = 0; i < cols; i++) { res += mat[0][i] * rhs[i]; } return res; } // 外積 Matrix cross(const Matrix& rhs) const { assert(rows == 1 && rhs.rows == 1 && cols == rhs.cols && cols == 3); Matrix res(1, 3); res.mat[0][0] = mat[0][1] * rhs.mat[0][2] - mat[0][2] * rhs.mat[0][1]; res.mat[0][1] = mat[0][2] * rhs.mat[0][0] - mat[0][0] * rhs.mat[0][2]; res.mat[0][2] = mat[0][0] * rhs.mat[0][1] - mat[0][1] * rhs.mat[0][0]; return res; } // 累乗 Matrix pow(long long n) const { assert(rows == cols); Matrix res(rows, cols); Matrix x = *this; for (int i = 0; i < rows; i++) { res.mat[i][i] = 1; } while (n > 0) { if (n & 1) res *= x; x *= x; n >>= 1; } return res; } }; template void print(Matrix a, int w = 1) { cout << "Matrix: " << a.rows << " x " << a.cols << endl; for (int i = 0; i < a.rows; i++) { for (int j = 0; j < a.cols; j++) { cout << right << setw(w); cout << a.mat[i][j] << " \n"[j == a.cols - 1]; } } } void solve() { vector> a(2, vector(2)); rep(i, 2) rep(j, 2) cin >> a[i][j]; Matrix A(a); A = A.pow(3); rep(i,2) rep(j,2) cout << A[i][j] << " \n"[j==1]; } int main() { uint t = 1; // cin >> t; while (t--) { solve(); } }