#include <bits/stdc++.h>
using namespace std;
inline long long Getint() {
  char ch = getchar();
  long long x = 0, fh = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    (x *= 10) += ch ^ 48;
    ch = getchar();
  }
  return x * fh;
}
const long long mod = 998244353;
const int N = (1 << 17) + 5;
int K, n, fin;
long long a[N], b[N], c[N], inv[N];
vector<int> s[N];
inline long long Inc(long long x, long long y) {
  return (x += y) >= mod ? x - mod : x;
}
inline long long Dec(long long x, long long y) {
  return (x -= y) < 0 ? x + mod : x;
}
inline long long Ksm(long long x, long long y) {
  long long tmp = 1;
  while (y) {
    if (y & 1) tmp = tmp * x % mod;
    y >>= 1;
    if (y) x = x * x % mod;
  }
  return tmp;
}
inline void FWT(vector<int>& F, int len, int f) {
  for (int i = 1; i < len; i <<= 1) {
    for (int j = 0; j < len; j += i << 1) {
      for (int k = 0; k < i; k++) {
        long long x = F[j + k], y = F[i + j + k];
        F[j + k] = Inc(x, y);
        F[i + j + k] = Dec(x, y);
      }
    }
  }
  if (f == 1) return;
  long long iv = inv[len];
  for (int i = 0; i <= len - 1; i++) F[i] = F[i] * iv % mod;
}
int main() {
  long long x, y, z;
  n = Getint();
  K = Getint();
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= N - 1; i++) {
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  }
  for (int i = 0; i <= 2; i++) a[i] = Getint() % mod;
  for (int i = 0; i <= (1 << 2) - 1; i++) {
    for (int j = 0; j <= 1; j++)
      b[i] = Inc(b[i], (i >> j) & 1 ? Dec(0, a[j]) : a[j]);
  }
  for (int i = 0; i <= (1 << 2) - 1; i++) {
    s[i].resize(1 << K);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 2; j++) c[j] = Getint();
    fin ^= c[2];
    for (int j = 0; j <= 2; j++) c[j] ^= c[2];
    for (int j = 0; j <= (1 << 2) - 1; j++) {
      int t = 0;
      for (int k = 0; k <= 1; k++)
        if ((j >> k) & 1) t ^= c[k];
      s[j][t]++;
    }
  }
  for (int i = 0; i <= (1 << 2) - 1; i++) {
    FWT(s[i], 1 << K, 1);
  }
  vector<int> ans(1 << K);
  for (int i = 0; i <= (1 << K) - 1; i++) {
    vector<int> t(1 << 2);
    for (int j = 0; j <= (1 << 2) - 1; j++) t[j] = s[j][i];
    FWT(t, 1 << 2, -1);
    ans[i] = 1;
    for (int j = 0; j <= (1 << 2) - 1; j++)
      ans[i] = ans[i] * Ksm(b[j] + a[2], t[j]) % mod;
  }
  FWT(ans, 1 << K, -1);
  for (int i = 0; i <= (1 << K) - 1; i++) {
    cout << ans[i ^ fin] << ' ';
  }
  cout << '\n';
  return 0;
}
