#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MOD = 998244353;
const int MAXROWS = 100000;
const int NITEMS = 3;
const int MAXCOLBITS = 17;
const int INV2 = (MOD + 1) / 2;
void inc(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}
void dec(int &a, int b) { inc(a, MOD - b); }
int pw(int x, int n) {
  int ret = 1;
  while (true) {
    if (n & 1) ret = (long long)ret * x % MOD;
    if ((n >>= 1) == 0) return ret;
    x = (long long)x * x % MOD;
  }
}
int nrows, colbits;
int itemweight[NITEMS];
int cols[MAXROWS][NITEMS];
int ways[1 << (MAXCOLBITS + NITEMS)];
int prod[1 << MAXCOLBITS];
void wht(int *a, int nbits) {
  for (int bit = (0); bit < (nbits); ++bit)
    for (int off = 0; off < (1 << nbits); off += 2 << bit)
      for (int i = (0); i < (1 << bit); ++i) {
        int x = a[off + i], y = a[off + (1 << bit) + i];
        a[off + i] = a[off + (1 << bit) + i] = x;
        inc(a[off + i], y);
        dec(a[off + (1 << bit) + i], y);
      }
}
void solve() {
  for (int mask = (0); mask < (1 << (colbits + NITEMS)); ++mask) ways[mask] = 0;
  for (int i = (0); i < (nrows); ++i)
    for (int jmask = (0); jmask < (1 << NITEMS); ++jmask) {
      int mask = 0;
      for (int j = (0); j < (NITEMS); ++j)
        if (jmask & (1 << j)) mask ^= cols[i][j] ^ (1 << (colbits + j));
      inc(ways[mask], 1);
    }
  wht(ways, colbits + NITEMS);
  int mltways = 1;
  for (int i = (0); i < (NITEMS); ++i)
    mltways = (long long)mltways * INV2 % MOD;
  for (int mask = (0); mask < (1 << (colbits + NITEMS)); ++mask)
    ways[mask] = (long long)ways[mask] * mltways % MOD;
  for (int mask = (0); mask < (1 << colbits); ++mask) {
    prod[mask] = 1;
    for (int jmask = (0); jmask < (1 << NITEMS); ++jmask) {
      int exp = ways[mask + (jmask << colbits)];
      if (exp == 0) continue;
      int cur = 0;
      for (int j = (0); j < (NITEMS); ++j)
        if (jmask & (1 << j))
          dec(cur, itemweight[j]);
        else
          inc(cur, itemweight[j]);
      prod[mask] = (long long)prod[mask] * pw(cur, exp) % MOD;
    }
  }
  wht(prod, colbits);
  int mltprod = 1;
  for (int i = (0); i < (colbits); ++i)
    mltprod = (long long)mltprod * INV2 % MOD;
  for (int mask = (0); mask < (1 << colbits); ++mask)
    prod[mask] = (long long)prod[mask] * mltprod % MOD;
}
void run() {
  scanf("%d%d", &nrows, &colbits);
  for (int i = (0); i < (NITEMS); ++i) scanf("%d", &itemweight[i]);
  for (int i = (0); i < (nrows); ++i)
    for (int j = (0); j < (NITEMS); ++j) scanf("%d", &cols[i][j]);
  solve();
  for (int i = (0); i < (1 << colbits); ++i) {
    if (i != 0) printf(" ");
    printf("%d", prod[i]);
  }
  puts("");
}
int main() {
  run();
  return 0;
}
