FWT(OR, AND, XOR)

/*
  Author : lifehappy
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1 << 18, mod = 998244353, inv2 = 499122177;

ll A[N], B[N], n;

ll quick_pow(ll a, int n) {
  ll ans = 1;
  while(n) {
    if(n & 1) ans = ans * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ans;
}

ll inv(ll x) {
  return quick_pow(x, mod - 2);
}

namespace fwt_or {
  ll a[N], b[N], n;

  void init() {
    for(int i = 0; i < n; i++) {
      a[i] = A[i];
      b[i] = B[i];
    }
  }

  void fwt(ll * f, int rev) {
    for(int i = 1; i < n; i <<= 1) {
      for(int p = i << 1, j = 0; j < n; j += p) {
        for(int k = 0; k < i; k++) {
          f[i + j + k] = ((f[i + j + k] + rev * f[j + k]) % mod + mod) % mod;
        }
      }
    }
  }

  void solve() {
    init();
    fwt(a, 1);
    fwt(b, 1);
    for(int i = 0; i < n; i++) {
      a[i] = a[i] * b[i] % mod;
    }
    fwt(a, -1);
    for(int i = 0; i < n; i++) {
      printf("%lld%c", a[i], i + 1 == n ? '\n' : ' ');
    }
  }
}

namespace fwt_and {
  ll a[N], b[N], n;

  void init() {
    for(int i = 0; i < n; i++) {
      a[i] = A[i];
      b[i] = B[i];
    }
  }

  void fwt(ll * f, int rev) {
    for(int i = 1; i < n; i <<= 1) {
      for(int p = i << 1, j = 0; j < n; j += p) {
        for(int k = 0; k < i; k++) {
          f[j + k] = ((f[j + k] + rev * f[i + j + k]) % mod + mod) % mod;
        }
      }
    }
  }

  void solve() {
    init();
    fwt(a, 1);
    fwt(b, 1);
    for(int i = 0; i < n; i++) {
      a[i] = a[i] * b[i] % mod;
    }
    fwt(a, -1);
    for(int i = 0; i < n; i++) {
      printf("%lld%c", a[i], i + 1 == n ? '\n' : ' ');
    }
  }
}

namespace fwt_xor {
  ll a[N], b[N], n;
  
  void init() {
    for(int i = 0; i < n; i++) {
      a[i] = A[i];
      b[i] = B[i];
    }
  }

  void fwt(ll * f, int rev) {
    for(int i = 1; i < n; i <<= 1) {
      for(int p = i << 1, j = 0; j < n; j += p) {
        for(int k = 0; k < i; k++) {
          ll x = f[j + k], y = f[i + j + k];
          if(rev == 1) {
            f[j + k] =  (x + y) % mod;
            f[i + j + k] = (x - y + mod) % mod;
          }
          else {
            f[j + k] = 1ll * inv2 * (x + y) % mod;
            f[i + j + k] = 1ll * inv2 * ((x - y + mod) % mod) % mod;
          }
        }
      }
    }
  }

  void solve() {
    init();
    fwt(a, 1);
    fwt(b, 1);
    for(int i = 0; i < n; i++) {
      a[i] = a[i] * b[i] % mod;
    }
    fwt(a, -1);
    for(int i = 0; i < n; i++) {
      printf("%lld%c", a[i], i + 1 == n ? '\n' : ' ');
    }
  }
}

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  scanf("%d", &n);
  n = 1 << n;
  for(int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  for(int i = 0; i < n; i++) {
    scanf("%d", &B[i]);
  }
  fwt_or::n = n, fwt_and::n = n, fwt_xor::n = n;
  fwt_or::solve();
  fwt_and::solve();
  fwt_xor::solve();
  return 0;
}