#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1, ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = (s << 3) + (s << 1) + ch - 48;
    ch = getchar();
  }
  return s * w;
}
const long long maxn = 1.5e5 + 50, mod = 998244353, inv2 = 499122177,
                mxor[2][2] = {1, 1, 1, -1},
                Imxor[2][2] = {inv2, inv2, inv2, -inv2};
long long n, K, X, Y, Z;
long long f1[maxn], f2[maxn], f3[maxn], g[maxn];
inline long long ksm(long long a, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = res * a % mod;
    p >>= 1;
    a = a * a % mod;
  }
  return res;
}
void fwt(long long *f, const long long mat[2][2]) {
  for (long long len = 2; len <= K; len <<= 1) {
    for (long long i = 0; i + len - 1 < K; i += len) {
      for (long long j = i; j < i + len / 2; j++) {
        long long x = f[j], y = f[j + len / 2];
        f[j] = mat[0][0] * x % mod + mat[0][1] * y % mod;
        f[j] %= mod;
        f[j + len / 2] = mat[1][0] * x % mod + mat[1][1] * y % mod;
        f[j + len / 2] %= mod;
      }
    }
  }
}
signed main() {
  long long sav = 0;
  n = read();
  K = 1 << read();
  X = read();
  Y = read();
  Z = read();
  for (long long i = 1; i <= n; i++) {
    long long a = read(), b = read(), c = read();
    sav ^= a;
    b ^= a;
    c ^= a;
    f1[b]++;
    f2[c]++;
    f3[b ^ c]++;
  }
  fwt(f1, mxor);
  fwt(f2, mxor);
  fwt(f3, mxor);
  long long s1 = (X + Y + Z) % mod, s2 = (X + Y - Z) % mod,
            s3 = (X - Y + Z) % mod, s4 = (X - Y - Z) % mod;
  for (long long i = 0; i < K; i++) {
    long long c1 = (n + f1[i] + f2[i] + f3[i]) / 4;
    long long c2 = (n + f1[i] - 2 * c1) / 2;
    long long c3 = (n + f2[i] - 2 * c1) / 2;
    long long c4 = (n + f3[i] - 2 * c1) / 2;
    g[i] =
        ksm(s1, c1) * ksm(s2, c2) % mod * ksm(s3, c3) % mod * ksm(s4, c4) % mod;
  }
  fwt(g, Imxor);
  for (long long i = 0; i < K; i++) {
    printf("%lld ", (g[i ^ sav] + mod) % mod);
  }
  return 0;
}
