#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; char buf[110]; UInt readPoly() { fgets(buf, sizeof(buf), stdin); UInt ret = 0; for (int e = 0; e < 32; ++e) { ret |= (UInt)(buf[e << 1] - '0') << e; } return ret; } /* (a0 b0 + a1 b1), (a0 b1 + a1 b0) (a0 + a1) (b0 + b1), (a0 b1 + a1 b0) (a0 + a1) (b0 + b1), ((a0 + a1) b1 + a1 (b0 + b1)) */ constexpr int MAX_N = 17; int N; UInt A[1 << MAX_N]; UInt B[1 << MAX_N]; UInt C[1 << MAX_N]; UInt zas[1 << MAX_N][MAX_N + 1]; UInt zbs[1 << MAX_N][MAX_N + 1]; UInt zcs[1 << MAX_N][MAX_N + 1]; int main() { for (; fgets(buf, sizeof(buf), stdin); ) { N = atoi(buf); for (int h = 0; h < 1 << N; ++h) A[h] = readPoly(); for (int h = 0; h < 1 << N; ++h) B[h] = readPoly(); for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) A[h] ^= A[h | 1 << i]; for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) B[h] ^= B[h | 1 << i]; #ifdef LOCAL memset(C, 0, sizeof(C)); memset(zas, 0, sizeof(zas)); memset(zbs, 0, sizeof(zbs)); memset(zcs, 0, sizeof(zcs)); #endif for (int h = 0; h < 1 << N; ++h) zas[h][__builtin_popcount(h)] = A[h]; for (int h = 0; h < 1 << N; ++h) zbs[h][__builtin_popcount(h)] = B[h]; for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) { const int hh = h | 1 << i; for (int k = 0; k <= N; ++k) zas[hh][k] ^= zas[h][k]; } for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) { const int hh = h | 1 << i; for (int k = 0; k <= N; ++k) zbs[hh][k] ^= zbs[h][k]; } for (int h = 0; h < 1 << N; ++h) { for (int k = 0; k <= N; ++k) for (int l = 0; l <= N - k; ++l) { zcs[h][k + l] ^= clmul(zas[h][k], zbs[h][l]); } } for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) { const int hh = h | 1 << i; for (int k = 0; k <= N; ++k) zcs[hh][k] ^= zcs[h][k]; } for (int h = 0; h < 1 << N; ++h) C[h] = zcs[h][__builtin_popcount(h)]; for (int i = 0; i < N; ++i) for (int h = 0; h < 1 << N; ++h) if (!(h & 1 << i)) C[h] ^= C[h | 1 << i]; 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; }