#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } #pragma GCC target("pclmul", "sse2", "sse4.1") #include #include #include __int64_t clmul(__int64_t x, __int64_t y) { __m128i x_ = _mm_set_epi64x(0, x); __m128i y_ = _mm_set_epi64x(0, y); __m128i z_ = _mm_clmulepi64_si128(x_, y_, 0); return _mm_extract_epi64(z_, 0); } using UInt = unsigned long long; UInt readPoly() { UInt ret = 0; for (int e = 0; e < 32; ++e) { int x; scanf("%d", &x); ret |= ((UInt)x) << e; } return ret; } vector mul(int n, vector as, vector bs) { vector cs(1 << n, 0); if (n <= 8) { for (int ha = 0; ha < 1 << n; ++ha) for (int hb = 0; hb < 1 << n; ++hb) { cs[ha ^ hb] ^= clmul(as[ha], bs[hb]); } } else { --n; vector as0(as.begin(), as.begin() + (1 << n)); vector bs0(bs.begin(), bs.begin() + (1 << n)); vector as1(as.begin() + (1 << n), as.end()); vector bs1(bs.begin() + (1 << n), bs.end()); const auto cs0 = mul(n, as0, bs0); const auto cs1 = mul(n, as1, bs1); for (int h = 0; h < 1 << n; ++h) as0[h] ^= as1[h]; for (int h = 0; h < 1 << n; ++h) bs0[h] ^= bs1[h]; const auto cs2 = mul(n, as0, bs0); for (int h = 0; h < 1 << n; ++h) cs[h] = cs0[h] ^ cs1[h]; for (int h = 0; h < 1 << n; ++h) cs[1 << n | h] = cs[h] ^ cs2[h]; } return cs; } int main() { int N; vector A, B; for (; ~scanf("%d", &N); ) { A.resize(1 << N); for (int h = 0; h < 1 << N; ++h) A[h] = readPoly(); B.resize(1 << N); for (int h = 0; h < 1 << N; ++h) B[h] = readPoly(); const auto C = mul(N, A, B); for (int h = 0; h < 1 << N; ++h) { for (int e = 0; e < 63; ++e) { if (e) putchar(' '); putchar('0' + (C[h] >> e & 1)); } puts(""); } } return 0; }