#include using namespace std; typedef pair pii; typedef long long ll; typedef vector vi; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define ALL(c) (c).begin(),(c).end() #define dump(x) cout << #x << " = " << (x) << endl constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); } template ostream& operator<<(ostream& os, const pair& p) { os<<"("< ostream& operator<<(ostream& os, const vector& v) { os<<"{"; rep(i, v.size()) { if (i) os<<","; os< mat; int get_rank(mat &A) //mod 2 { const int n = A.size(), m = A[0].size(); int r = 0; for (int i = 0; r < n && i < m; ++i) { int pivot = r; for (int j = r+1; j < n; ++j) { if (A[j][i]) { pivot = j; break; } } swap(A[pivot], A[r]); if (A[r][i] == 0) continue; for (int j = r+1; j < n; ++j) { if (A[j][i]) { for (int k = i; k < m; ++k) { A[j][k] ^= A[r][k]; } } } ++r; } return r; } int main() { int N, M, X; cin >> N >> M >> X; mat m(M + 30, vi(N + 1, 0)); vi a(N); rep(i, N) cin >> a[i]; for (int i = 0; i < 30; ++i) { rep(j, N) { m[i][j] = (a[j] >> i) & 1; } m[i][N] = (X >> i) & 1; } rep(i, M) { int t, l, r; cin >> t >> l >> r; --l; --r; for (int k = l; k <= r; ++k) { m[i+30][k] = 1; } m[i+30][N] = t; } mat m2(M + 30, vi(N)); rep(i, m2.size()) { rep(j, m2[i].size()) { m2[i][j] = m[i][j]; } } int r = get_rank(m2); get_rank(m); if (r > N || m[r][N] != 0) { puts("0"); } else { ll ans = 1; rep(i, N-r) { ans = ans * 2 % MOD; } cout << ans << endl; } return 0; }