#include <bits/stdc++.h>
using namespace std;
const int N2 = (1 << 21) + 5, N = 33, mod = 998244353;
int ksm(long long a, int b, int c = 1) {
  for (; b; b /= 2, a = a * a % mod)
    if (b & 1) c = c * a % mod;
  return c;
}
inline void reduce(int& x) { x += x >> 31 & mod; }
void fwt(int* a, int n, int flag = 0) {
  for (int i = 0; i < n; ++i) {
    int t = 1 << i;
    for (int j = 0; j < (1 << n); j += t * 2) {
      int *f = a + j, *g = a + j + t;
      for (int k = 0; k < t; ++k) {
        int s = g[k];
        reduce(g[k] = f[k] - s);
        reduce(f[k] += s - mod);
      }
    }
  }
  if (flag) {
    long long iv = mod - ((mod - 1) >> n);
    for (int i = 0; i < (1 << n); ++i) a[i] = (long long)a[i] * iv % mod;
  }
}
int n, m, K, buf[N2], *f[N2], a[N], b[N], c[N2], g[N2], ans[N2];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  K = 3;
  for (int i = 0; i < (1 << K); ++i) f[i] = buf + i * ((1 << m) + 1);
  for (int i = 0; i < K; ++i) cin >> a[i];
  for (int i = 0; i < (1 << K); ++i)
    for (int j = 0; j < K; ++j)
      if (i >> j & 1)
        reduce(c[i] -= a[j]);
      else
        reduce(c[i] += a[j] - mod);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < K; ++j) cin >> b[j];
    for (int j = 0, k = 0, l = 0; j < (1 << K); ++j)
      ++f[k][l], l ^= b[__builtin_ctz(j + 1)], k ^= ((j + 1) & -(j + 1));
  }
  for (int i = 0; i < (1 << K); ++i) fwt(f[i], m);
  for (int i = 0; i < (1 << m); ++i) {
    for (int j = 0; j < (1 << K); ++j) g[j] = f[j][i];
    fwt(g, K, 1);
    ans[i] = 1;
    for (int j = 0; j < (1 << K); ++j) ans[i] = ksm(c[j], g[j], ans[i]);
  }
  fwt(ans, m, 1);
  for (int i = 0; i < (1 << m); ++i) cout << ans[i] << " \n"[i == (1 << m) - 1];
  return 0;
}
