#include using namespace std; using longll = long long; struct Mat { longll a, b, c, d; // [ [a b], [c d] ] }; Mat mul(const Mat& x, const Mat& y) { // x * y return Mat{ x.a * y.a + x.b * y.c, x.a * y.b + x.b * y.d, x.c * y.a + x.d * y.c, x.c * y.b + x.d * y.d }; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); longll A, B, C, D, Ap, Bp, Cp, Dp; cin >> A >> B >> C >> D >> Ap >> Bp >> Cp >> Dp; Mat M{A, B, C, D}; Mat Mp{Ap, Bp, Cp, Dp}; Mat P = mul(M, Mp); // MM' Mat R = mul(P, P); // (MM')(MM') = MM'MM' cout << R.a << " " << R.b << "\n"; cout << R.c << " " << R.d << "\n"; return 0; }