#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
const int N = 1000100, mo = 998244353, n2 = 499122177, n4 = 748683265;
int A(int x, int y) { return (0ll + x + y + mo) % mo; }
int M(int x, int y) { return 1ll * x * y % mo; }
int ksm(int x, int y) {
  int s = 1, t = x;
  while (y) {
    if (y & 1) s = M(s, t);
    y >>= 1, t = M(t, t);
  }
  return s;
}
int ni(int x) { return ksm(x, mo - 2); }
int n, k, a[N], b[N], c[N], f1[N], f2[N], f3[N], s[N], x, y, z, sum, lim = 1, l;
void input() {
  n = read(), k = read();
  x = read(), y = read(), z = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read(), b[i] = read(), c[i] = read();
    sum ^= a[i], b[i] ^= a[i], c[i] ^= a[i];
  }
  for (int i = 1; i <= n; i++) {
    f1[b[i]]++;
    f2[c[i]]++;
    f3[b[i] ^ c[i]]++;
  }
}
void fwt(int *T, int type) {
  for (int k = 1; k < lim; k <<= 1) {
    for (int j = 0; j < lim; j += (k << 1))
      for (int i = j; i < j + k; i++) {
        int x = T[i], y = T[i + k];
        if (type == 1)
          T[i] = A(x, y), T[i + k] = A(x, -y);
        else
          T[i] = M(A(x, y), n2), T[i + k] = M(A(x, -y), n2);
      }
  }
}
int main() {
  input();
  lim = (1 << k);
  fwt(f1, 1);
  fwt(f2, 1);
  fwt(f3, 1);
  int x1 = ((0ll + x + y + z) % mo + mo) % mo;
  int x2 = ((0ll + x + y - z) % mo + mo) % mo;
  int x3 = ((0ll + x - y + z) % mo + mo) % mo;
  int x4 = ((0ll + x - y - z) % mo + mo) % mo;
  for (int i = 0; i < lim; i++) {
    int p1 = f1[i], p2 = f2[i], p3 = f3[i];
    int a = M(((0ll + n + p1 + p2 + p3) % mo + mo) % mo, n4);
    int b = M(((0ll + n + p1 - p2 - p3) % mo + mo) % mo, n4);
    int c = M(((0ll + n - p1 + p2 - p3) % mo + mo) % mo, n4);
    int d = M(((0ll + n - p1 - p2 + p3) % mo + mo) % mo, n4);
    s[i] = M(M(ksm(x1, a), ksm(x2, b)), M(ksm(x3, c), ksm(x4, d)));
  }
  fwt(s, -1);
  for (int i = 0; i < lim; i++) cout << s[i ^ sum] << ' ';
  return 0;
}
