#include using namespace std; typedef long long ll; #define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0) int main() { int n,m,x; cin >> n >> m >> x; vector> b(n,vector(30+m,0)); vector xs(30+m,0); for (int i = 0;i < 30;++i) xs[i] = ((x>>i)&1); for (int i = 0;i < n;++i) { int a; cin >> a; for (int j = 0;j < 30;++j) b[i][j] = ((a>>j)&1); } for (int i = 0;i < m;++i) { int t,l,r; cin >> t >> l >> r; xs[i+30] = t; for (int j = l-1;j < r;++j) b[j][i+30] = 1; } int i = 0; for (int j = 0;j < m+30;++j) { if (!b[i][j]) for (int k = i;k < n;++k) if (b[k][j]) { for (int l = 0;l < m+30;++l) b[i][l] ^= b[k][l]; break; } if (b[i][j]) { for (int k = 0;k < n;++k) if (k != i && b[k][j]) for (int l = 0;l < m+30;++l) b[k][l] ^= b[i][l]; ++i; } if (i == n) break; } vector c(m+30,0); for (int i = 0;i < n;++i) { for (int j = 0;j < m+30;++j) if (b[i][j]) { if (xs[j]^c[j]) for (int k = 0;k < m+30;++k) c[k] ^= b[i][k]; break; } } ll ans = 0; if (xs == c) { int cnt = 0; for (int i = 0;i < n;++i) { bool ok = true; for (int j = 0;j < m+30;++j) if (b[i][j]) { ok = false; break; } if (ok) cnt++; } ans = 1; for (int i = 0;i < cnt;++i) { ans <<= 1; ans %= (int)1e9+7; } } cout << ans << endl; return 0; }