#include static inline constexpr void mul(std::array, 2>& result, const std::array, 2>& a, const std::array, 2>& b) noexcept { for (uint_fast32_t i = 0; i != 2; ++i) for (uint_fast32_t j = 0; j != 2; ++j) result[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j]; } static inline constexpr std::array, 2> solve(const std::array, 2>, 2>& M) noexcept { std::array, 2>, 2> dp = { std::array, 2>{ std::array{ 1, 0 }, std::array{ 0, 1 } }, std::array, 2>{ std::array{ 1, 0 }, std::array{ 0, 1 } } }; for (uint_fast32_t i = 0; i != 4; ++i) mul(dp[(i & 1) ^ 1], dp[i & 1], M[i & 1]); return dp[0]; } static inline void output(const std::array, 2>& ans) noexcept { std::cout << ans[0][0] << ' ' << ans[0][1] << '\n' << ans[1][0] << ' ' << ans[1][1] << '\n'; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::array, 2>, 2> M; uint_fast32_t i, j, k; for (i = 0; i != 2; ++i) for (j = 0; j != 2; ++j) for (k = 0; k != 2; ++k) std::cin >> M[i][j][k]; output(solve(M)); return 0; }