#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\t";
  err(++it, args...);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2>& v) {
  c << "(" << v.first << "," << v.second << ")";
  return c;
}
template <template <class...> class TT, class... T>
ostream& operator<<(ostream& out, TT<T...>& c) {
  out << "{ ";
  for (auto& x : c) out << x << " ";
  out << "}";
  return out;
}
const int LIM = 1e5 + 5, MOD = 998244353;
int t, n, m, k, x, y, w;
inline long long powm(long long x, long long pw, long long Mod = MOD) {
  x %= Mod;
  long long res = 1;
  while (pw) {
    if (pw & 1LL) res = ((res * x)) % Mod;
    pw >>= 1;
    x = ((x * x)) % Mod;
  }
  return res;
}
inline long long inv(long long x, long long Mod = MOD) {
  return powm(x, Mod - 2, Mod);
}
template <int mod>
struct FWHT {
  vector<int> fwht(vector<int> P, bool inverse, bool nomod = 0) {
    int sz = P.size();
    for (int len = 1; 2 * len <= sz; len <<= 1) {
      for (int i = 0; i < sz; i += 2 * len) {
        for (int j = 0; j < len; ++j) {
          int u = P[i + j];
          int v = P[i + len + j];
          if (nomod) {
            P[i + j] = (u + v);
            P[i + len + j] = (u - v);
          } else {
            P[i + j] = (u + v) % mod;
            P[i + len + j] = (u - v + mod) % mod;
          }
        }
      }
    }
    if (inverse) {
      long long iv = inv(sz, mod);
      for (int i = 0; i < sz; ++i) P[i] = P[i] * iv % mod;
    }
    return P;
  }
  vector<int> mult(vector<int> A, vector<int> B) {
    A = fwht(A, 0);
    B = fwht(B, 0);
    for (int i = 0; i < A.size(); ++i) A[i] = A[i] * 1LL * B[i] % mod;
    return fwht(A, 1);
  }
  vector<int> pow(vector<int> A, long long k) {
    A = fwht(A, 0);
    for (int i = 0; i < A.size(); ++i) A[i] = powm(A[i], k);
    return fwht(A, 1);
  }
};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  int sz = (1 << k);
  vector<int> A(sz, 0), B(sz, 0), C(sz, 0), D(sz, 0);
  long long o1, o2, o3;
  cin >> o1 >> o2 >> o3;
  int totxor = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y >> w;
    totxor ^= x;
    y ^= x, w ^= x;
    A[y]++;
    B[w]++;
    C[y ^ w]++;
  }
  FWHT<MOD> f;
  A = f.fwht(A, 0, 1), B = f.fwht(B, 0, 1), C = f.fwht(C, 0, 1);
  for (int i = 0; i < sz; ++i) {
    int x1 = (n + A[i]) / 2, x2 = (n + B[i]) / 2, x3 = (n + C[i]) / 2;
    int a1 = (x1 + x2 + x3 - n) / 2, b1 = x2 - a1, c1 = x1 - a1, d1 = x3 - a1;
    D[i] = ((powm(o1 + o2 + o3, a1) * powm(o1 - o2 + o3 + MOD, b1) % MOD) *
            powm(o1 + o2 - o3 + MOD, c1) % MOD) *
           powm(o1 - o2 - o3 + MOD + MOD, d1) % MOD;
  }
  D = f.fwht(D, 1);
  for (int i = 0; i < sz; ++i) cout << D[i ^ totxor] << " ";
  cout << '\n';
  return 0;
}
