#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int N = 5e5 + 5;   long long l[N], r[N], x[N], d[N], s[N], pre[N], dp[N];   int n, m;   inline long long solve(int u) {     for (int i = 1; i <= n; i++) d[i] = s[i] = pre[i] = 0;     for (int i = 1; i <= m; i++) {       if (x[i] >> u & 1) {         d[r[i] + 1]--;         d[l[i]]++;       } else {         pre[r[i]] = max(pre[r[i]], l[i]);       }     }     dp[0] = s[0] = 1;     for (int i = 1; i <= n; i++) {       d[i] += d[i - 1];       pre[i] = max(pre[i], pre[i - 1]);       if (d[i] > 0)         dp[i] = 0;       else if (pre[i - 1] > 0)         dp[i] = (s[i - 1] - s[pre[i - 1] - 1]) % mod;       else         dp[i] = s[i - 1];       s[i] = (s[i] + s[i - 1] + dp[i]) % mod;     }     return pre[n] == 0 ? s[n] % mod : (s[n] - s[pre[n] - 1]) % mod;   }   int main() {     int k;     scanf( %d%d%d , &n, &k, &m);     for (int i = 1; i <= m; i++) scanf( %lld%lld%lld , &l[i], &r[i], &x[i]);     long long ans = 1;     for (int i = 0; i < k; i++) ans = ans * solve(i) % mod;     printf( %lld n , (ans + mod) % mod);     return 0;   }   