#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 11, mod = 998244353, inv2 = (mod + 1) / 2,
          inv4 = 1ll * inv2 * inv2 % mod;
int A[N], B[N], C[N], n, x, y, z, k, tmp, ans[N];
inline int fp(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) res = 1ll * res * a % mod;
  return res;
}
inline void fwt(int *a, int n, int f) {
  for (register int i = 1; i < n; i <<= 1)
    for (register int j = 0; j < n; j += i + i)
      for (register int k = j; k < i + j; ++k) {
        int x = a[k], y = a[i | k];
        a[k] = (x + y) % mod, a[i | k] = (x - y + mod) % mod;
        if (f == -1)
          a[k] = 1ll * a[k] * inv2 % mod,
          a[i | k] = 1ll * a[i | k] * inv2 % mod;
      }
}
int main() {
  scanf("%d%d%d%d%d", &n, &k, &x, &y, &z);
  for (register int i = 1; i <= n; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    tmp ^= a;
    ++A[a ^ b], ++B[a ^ c], ++C[b ^ c];
  }
  fwt(A, (1 << k), 1), fwt(B, (1 << k), 1), fwt(C, (1 << k), 1);
  for (register int i = 0; i <= (1 << k) - 1; ++i) {
    int a = 1ll * (0ll + n + A[i] + B[i] + C[i]) * inv4 % mod,
        b = 1ll * (0ll + n + A[i] - B[i] - C[i]) * inv4 % mod,
        c = 1ll * (0ll + n - A[i] + B[i] - C[i]) * inv4 % mod,
        d = 1ll * (0ll + n - A[i] - B[i] + C[i]) * inv4 % mod;
    a = (a + mod) % mod, b = (b + mod) % mod, c = (c + mod) % mod,
    d = (d + mod) % mod;
    ans[i] = 1ll * fp((0ll + x + y + z) % mod, a) *
             fp((0ll + x + y - z) % mod, b) % mod *
             fp((0ll + x - y + z) % mod, c) % mod *
             fp((0ll + x - y - z) % mod, d) % mod;
    ans[i] = (ans[i] + mod) % mod;
  }
  fwt(ans, (1 << k), -1);
  for (register int i = 0; i <= (1 << k) - 1; ++i) printf("%d ", ans[i ^ tmp]);
  return 0;
}
