#include using namespace std; #include using namespace atcoder; vector> matrix_product(vector> A, vector> B) { int H = A.size(), W = B[0].size(), K = A[0].size(); vector> ret(H, vector(W)); for( int i = 0; i < H; i++ ) { for( int j = 0; j < W; j++ ) { for( int k = 0; k < K; k++ ) { ret[i][j] += A[i][k]*B[k][j]; } } } return ret; } int main() { int a, b, c, d, p, q, r, s; cin >> a >> b >> c >> d; vector> M = {{a, b}, {c, d}}, ans = {{1, 0}, {0, 1}}; ans = matrix_product(ans, M); ans = matrix_product(ans, M); ans = matrix_product(ans, M); cout << ans[0][0] << " " << ans[0][1] << endl; cout << ans[1][0] << " " << ans[1][1] << endl; }