#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char c = getchar();
  long long x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
const long long Mod = 998244353;
struct modint {
  long long x;
  modint(long long o = 0) {
    x = o % Mod + Mod;
    (x >= Mod) && (x -= Mod);
  }
  modint &operator=(long long o) { return x = o, *this; }
  modint &operator+=(modint o) {
    return x = x + o.x >= Mod ? x + o.x - Mod : x + o.x, *this;
  }
  modint &operator-=(modint o) {
    return x = x - o.x < 0 ? x - o.x + Mod : x - o.x, *this;
  }
  modint &operator*=(modint o) { return x = 1ll * x * o.x % Mod, *this; }
  modint &operator^=(long long b) {
    modint a = *this, c = 1;
    for (; b; b >>= 1, a *= a)
      if (b & 1) c *= a;
    return x = c.x, *this;
  }
  modint &operator/=(modint o) { return *this *= o ^= Mod - 2; }
  modint &operator+=(long long o) {
    return x = x + o >= Mod ? x + o - Mod : x + o, *this;
  }
  modint &operator-=(long long o) {
    return x = x - o < 0 ? x - o + Mod : x - o, *this;
  }
  modint &operator*=(long long o) { return x = 1ll * x * o % Mod, *this; }
  modint &operator/=(long long o) { return *this *= ((modint(o)) ^= Mod - 2); }
  template <class I>
  friend modint operator+(modint a, I b) {
    return a += b;
  }
  template <class I>
  friend modint operator-(modint a, I b) {
    return a -= b;
  }
  template <class I>
  friend modint operator*(modint a, I b) {
    return a *= b;
  }
  template <class I>
  friend modint operator/(modint a, I b) {
    return a /= b;
  }
  friend modint operator^(modint a, long long b) { return a ^= b; }
  friend bool operator==(modint a, long long b) { return a.x == b; }
  friend bool operator!=(modint a, long long b) { return a.x != b; }
  bool operator!() { return !x; }
  modint operator-() { return x ? Mod - x : 0; }
};
const long long M = 1e6 + 10;
long long n, m, x, y, z, sum, ans[M];
long long a[M], b[M], c[M];
struct poly {
  modint f[M];
} f, f1, f2, f3;
poly operator*(poly a, poly b) {
  for (long long i = 0; i < n; i++) a.f[i] = a.f[i] * b.f[i];
  return a;
}
void XOR(poly &a, modint x) {
  for (long long o = 2, k = 1; o <= n; o <<= 1, k <<= 1)
    for (long long i = 0; i < n; i += o)
      for (long long j = 0; j < k; j++) {
        modint x1 = a.f[i + j], x2 = a.f[i + j + k];
        a.f[i + j] = x1 + x2, a.f[i + j + k] = x1 - x2;
        a.f[i + j] *= x, a.f[i + j + k] *= x;
      }
}
signed main() {
  m = read(), n = 1 << read(), x = read(), y = read(), z = read();
  for (long long i = 1; i <= m; i++) {
    a[i] = read(), b[i] = read(), c[i] = read();
    b[i] ^= a[i], c[i] ^= a[i], sum ^= a[i], a[i] = 0;
    f1.f[b[i]] += 1, f2.f[c[i]] += 1, f3.f[b[i] ^ c[i]] += 1;
  }
  XOR(f1, 1), XOR(f2, 1), XOR(f3, 1);
  for (long long i = 0; i < n; i++) {
    modint s1 = f1.f[i], s2 = f2.f[i], s3 = f3.f[i];
    modint w1 = s1 + s2 + s3 + m, w2 = s1 - s2 - s3 + m, w3 = -s1 + s2 - s3 + m,
           w4 = -s1 - s2 + s3 + m;
    w1 /= 4, w2 /= 4, w3 /= 4, w4 /= 4;
    modint x1 = x + y + z, x2 = x + y - z, x3 = x - y + z, x4 = x - y - z;
    x1 = x1 ^ w1.x, x2 = x2 ^ w2.x, x3 = x3 ^ w3.x, x4 = x4 ^ w4.x;
    f.f[i] = x1 * x2 * x3 * x4;
  }
  XOR(f, modint(1) / 2);
  for (long long i = 0; i < n; i++) ans[i] = f.f[i ^ sum].x;
  for (long long i = 0; i < n; i++) cout << ans[i] << ' ';
  return 0;
}
