#include #define rep(i,n,m) for(int i = (n); i <(m); i++) #define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--) #define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;} #define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;} using namespace std; using ll = long long; const ll MOD = 1000000007; int main() { int N, M, X; cin >> N >> M >> X; // convert X as vector format vector target(400); rep(bit, 0, 30) if (((1<0) target[bit] = 1; vector> values(N, vector(400, 0)); rep(i, 0, N) { int A; cin >> A; int bit = 0; rep(bit, 0, 30) if (((1< 0) values[i][bit] = 1; } // restriction rep(i, 0, M) { int t, l, r; cin >> t >> l >> r; --l, --r; target[30+i] = t; rep(pos, l, r+1) values[pos][30+i] = 1; } // sweep method int rank = 0; vector msb(410, -1); rep(bit, 0, 400) { bool exists = false; rep(i, rank, N) { if (values[i][bit] == 1) { exists = true; // swap if (i != rank) { rep(j, 0, 400) swap(values[rank][j], values[i][j]); } break; } } if (!exists) continue; // sweep // cout << bit << ' ' << rank << endl; // pvec(values[rank]); rep(i, 0, N) { if (i==rank) continue; if (values[i][bit] == 0) continue; rep(j, 0, 400) values[i][j] ^= values[rank][j]; // cout << "add: " << i << endl; // pvec(values[i]); } msb[rank] = bit; ++rank; } // cout << rank << endl; // check ans vector status(400, 0); rank = 0; rep(bit, 0, 400) { if (target[bit] == 0) continue; while (msb[rank]bit) { cout << 0 << endl; return 0; } rep(i,0, 400) status[i] ^= values[rank][i]; ++rank; } bool is_ok = true; rep(bit,0,400) if (status[bit]!=target[bit]) is_ok = false; if (!is_ok) { cout << 0 << endl; return 0; } ll cnt = 1; rep(i, 0, N) { bool is_zero = true; rep(j,0,400) if (values[i][j] == 1) is_zero = false; if (is_zero) cnt = (cnt*2)%MOD; } cout << cnt << endl; return 0; }