#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, mod = 998244353;
namespace {
inline int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int kissme(int x, int y) {
  int c = 1;
  for (; y; y >>= 1, x = mul(x, x)) {
    if (y & 1) c = mul(c, x);
  }
  return c;
}
}  // namespace
struct info {
  int a[4][5];
  int calc(int x, int y, int z) {
    vector<int> c(4);
    c[0] = add(x, add(y, z));
    c[1] = add(x, sub(y, z));
    c[2] = add(x, sub(z, y));
    c[3] = sub(x, add(y, z));
    for (int i = 0, r; i < 4; i++) {
      r = -1;
      for (int j = i; j < 4; j++) {
        if (a[j][i]) {
          r = j;
          break;
        }
      }
      assert(~r);
      for (int j = i; j < 5; j++) {
        swap(a[i][j], a[r][j]);
      }
      int inv = kissme(a[i][i], mod - 2);
      for (int j = i + 1; j < 4; j++) {
        int tmp = mul(inv, a[j][i]);
        for (int k = i; k < 5; k++) {
          a[j][k] = sub(a[j][k], mul(tmp, a[i][k]));
        }
      }
    }
    int ans = 1;
    vector<int> f(4);
    for (int i = 3; ~i; i--) {
      f[i] = a[i][4];
      for (int j = i + 1; j < 4; j++) {
        f[i] = sub(f[i], mul(f[j], a[i][j]));
      }
      f[i] = mul(f[i], kissme(a[i][i], mod - 2));
      ans = mul(ans, kissme(c[i], f[i]));
    }
    return ans;
  }
} coef[maxn];
int n, dig, ax, ay, az, a[maxn], b[maxn], all;
void fwt(int *a) {
  for (int i = 1; i < 1 << dig; i <<= 1) {
    for (int j = 0; j < 1 << dig; j += i << 1) {
      for (int k = 0; k < i; k++) {
        int u = a[j + k], v = a[i + j + k];
        a[j + k] = add(u, v);
        a[i + j + k] = sub(u, v);
      }
    }
  }
}
int main(void) {
  scanf("%d%d%d%d%d", &n, &dig, &ax, &ay, &az);
  for (int i = 0, x; i < n; i++) {
    scanf("%d%d%d", &x, &a[i], &b[i]);
    a[i] ^= x;
    b[i] ^= x;
    all ^= x;
  }
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 1 << dig; j++) {
      coef[j].a[0][i] = i == 4 ? n : 1;
    }
  }
  for (int rep = 0; rep < 2; rep++) {
    int x = rand() % mod;
    int y = rand() % mod;
    int z = rand() % mod;
    vector<int> f(1 << dig);
    for (int i = 0; i < n; i++) {
      f[0] = add(f[0], x);
      f[a[i]] = add(f[a[i]], y);
      f[b[i]] = add(f[b[i]], z);
    }
    fwt(&f[0]);
    for (int i = 0; i < 1 << dig; i++) {
      coef[i].a[rep + 1][0] = add(x, add(y, z));
      coef[i].a[rep + 1][1] = add(x, sub(y, z));
      coef[i].a[rep + 1][2] = add(x, sub(z, y));
      coef[i].a[rep + 1][3] = sub(x, add(z, y));
      coef[i].a[rep + 1][4] = f[i];
    }
  }
  vector<int> f(1 << dig), ans(1 << dig);
  for (int i = 0; i < n; i++) {
    f[a[i] ^ b[i]]++;
  }
  fwt(&f[0]);
  for (int i = 0; i < 1 << dig; i++) {
    for (int j = 0; j < 4; j++) {
      coef[i].a[3][j] = j % 3 ? mod - 1 : 1;
    }
    coef[i].a[3][4] = f[i];
  }
  for (int i = 0; i < 1 << dig; i++) {
    f[i] = coef[i].calc(ax, ay, az);
  }
  fwt(&f[0]);
  for (int i = 0; i < 1 << dig; i++) {
    ans[i ^ all] = mul(f[i], kissme(1 << dig, mod - 2));
  }
  for (int i = 0; i < 1 << dig; i++) {
    printf("%d%c", ans[i], " \n"[i == (1 << dig) - 1]);
  }
  return 0;
}
