#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 17) + 10;
const int mod = 998244353;
const long long inv2 = (mod + 1) >> 1;
int n, logn, pown;
long long x, y, z, f1[maxn], f2[maxn], f3[maxn], f[maxn];
inline long long fpow(long long a, long long b) {
  long long ret = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) ret = ret * a % mod;
  return ret;
}
inline void FWT(long long *f, int n, int op) {
  long long x, y;
  for (int len = 1; len < n; len <<= 1)
    for (int R = len << 1, i = 0; i < n; i += R)
      for (int j = 0; j < len; j++) {
        x = f[i + j], y = f[i + j + len];
        f[i + j] = (x + y) % mod, f[i + j + len] = (x - y) % mod;
        if (op == -1)
          (f[i + j] *= inv2) %= mod, (f[i + j + len] *= inv2) %= mod;
      }
}
int main() {
  scanf("%d%d%lld%lld%lld", &n, &logn, &x, &y, &z);
  pown = 1 << logn;
  int a, b, c, val = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a, &b, &c);
    val ^= a, b ^= a, c ^= a;
    f1[b]++, f2[c]++, f3[b ^ c]++;
  }
  FWT(f1, pown, 1), FWT(f2, pown, 1), FWT(f3, pown, 1);
  long long s1 = (x + y + z) % mod, s2 = (x + y - z) % mod,
            s3 = (x - y + z) % mod, s4 = (x - y - z) % mod;
  for (int i = 0; i < pown; i++) {
    long long c1 = (n + f1[i] + f2[i] + f3[i]) / 4;
    f[i] = fpow(s1, c1) * fpow(s2, (n + f1[i] - 2 * c1) / 2) % mod *
           fpow(s3, (n + f2[i] - 2 * c1) / 2) % mod *
           fpow(s4, (n + f3[i] - 2 * c1) / 2) % mod;
  }
  FWT(f, pown, -1);
  for (int i = 0; i < pown; i++)
    printf("%lld ", (f[i ^ val] % mod + mod) % mod);
  putchar('\n');
  return 0;
}
