#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } template struct Matrix { int row, column; std::vector>mat; Matrix(int r = 0, int c = 0, T val = 0) :row(r), column(c) { mat = std::vector>(row, std::vector(column, val)); } std::vector& operator[](const int i) { return mat[i]; } Matrix& operator+=(const Matrix & other) { assert(row == other.row && column == other.column); for (int i = 0; i < row; ++i) { for (int j = 0; j < column; ++j) { mat[i][j] += other.mat[i][j]; } } return *this; } Matrix& operator-=(const Matrix & other) { assert(row == other.row && column == other.column); for (int i = 0; i < row; ++i) { for (int j = 0; j < column; ++j) { mat[i][j] -= other.mat[i][j]; } } return *this; } Matrix& operator*=(const Matrix & other) { assert(column == other.row); Matrix ret(row, other.column); for (int i = 0; i < row; ++i) { for (int k = 0; k < column; ++k) { for (int j = 0; j < other.column; ++j) { ret.mat[i][j] += mat[i][k] * other.mat[k][j]; } } } return *this = ret; } Matrix& operator*=(T k) { for (int i = 0; i < row; ++i) { for (int j = 0; j < column; ++j) { mat[i][j] *= k; } } return *this; } Matrix operator+(const Matrix other)const { return Matrix(*this) += other; } Matrix operator-(const Matrix other)const { return Matrix(*this) -= other; } Matrix operator*(const Matrix other)const { return Matrix(*this) *= other; } Matrix operator*(const T k)const { return Matrix(*this) *= k; } std::vector operator*(const std::vector other) const { assert(column == (int)other.size()); std::vector ret(row); for (int i = 0; i < row; ++i) { for (int j = 0; j < column; ++j) { ret[i] += mat[i][j] * other[j]; } } return ret; } Matrix pow(long long n) const { assert(row == column); if (n == 0) { Matrix e(row, column); for (int i = 0; i < row; ++i) e.mat[i][i] = 1; return e; } Matrix ret = pow(n >> 1); ret *= ret; if (n & 1) ret *= *this; return ret; } Matrix debug() { for (int i = 0; i < row; ++i) { for (int j = 0; j < column; ++j) std::cout << mat[i][j] << " "; std::cout << std::endl; } } }; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int a, b, c, d; cin >> a >> b >> c >> d; Matrix mat(2, 2, 0); mat[0][0] = a; mat[0][1] = b; mat[1][0] = c; mat[1][1] = d; cin >> a >> b >> c >> d; Matrix mat2(2, 2, 0); mat2[0][0] = a; mat2[0][1] = b; mat2[1][0] = c; mat2[1][1] = d; auto ans = mat * mat2; ans = ans * ans; rep(i, 2) { rep(j, 2)cout << ans[i][j] << " "; cout << endl; } return 0; }