#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define DEBUG_ //!!提出時にコメントアウト!! #ifdef DEBUG_ #define dump(x) cerr << #x << " = " << (x) << endl; #else #define dump(x) ; #endif #define equals(a,b) (fabs((a)-(b)) < EPS) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define SZ(x) ((int)(x).size()) #define pb push_back #define eb emplace_back //#define int long long typedef long long LL; typedef vector VI; typedef vector VL; typedef vector VVI; typedef vector VS; typedef pair PII; typedef pair PLL; template std::string printVector(const std::vector &data) { std::stringstream ss; std::ostream_iterator out_it(ss, ", "); ss << "["; std::copy(data.begin(), data.end() - 1, out_it); ss << data.back() << "]"; return ss.str(); } template void print_array(const T &ary, int size){ REP(i,size){ cout << ary[i] << " "; } cout << endl; } const int MOD = 1e9+7; const LL LINF = 1001002003004005006ll; const int INF = 1001001001; const double EPS = (1e-10); const int MAX_ROW = 350; const int MAX_COL = 350; struct BitMatrix { int H, W; bitset val[MAX_ROW]; BitMatrix(int m = 1, int n = 1) : H(m), W(n) {} inline bitset& operator [] (int i) {return val[i];} }; int GaussJordan(BitMatrix &A, bool is_extended = false) { int rank = 0; for (int col = 0; col < A.W; ++col) { if (is_extended && col == A.W - 1) break; int pivot = -1; for (int row = rank; row < A.H; ++row) { if (A[row][col]) { pivot = row; break; } } if (pivot == -1) continue; swap(A[pivot], A[rank]); for (int row = 0; row < A.H; ++row) { if (row != rank && A[row][col]) A[row] ^= A[rank]; } ++rank; } return rank; } int linear_equation(BitMatrix A, vector b, vector &res) { int m = A.H, n = A.W; BitMatrix M(m, n + 1); for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) M[i][j] = A[i][j]; M[i][n] = b[i]; } int rank = GaussJordan(M, true); // check if it has no solution for (int row = rank; row < m; ++row) if (M[row][n]) return -1; // answer res.assign(n, 0); for (int i = 0; i < rank; ++i) res[i] = M[i][n]; return rank; } signed main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(12); int N,M,X; cin >> N >> M >> X; VI A(N); REP(i,N) cin >> A[i]; BitMatrix B(32+M,N); VI res(32+M),res2; const int DIGIT = 32; REP(i,DIGIT){ REP(j,N){ if(A[j] & (1 << i)) B[i][j] = 1; } if(X & (1 << i)) res[i] = 1; } REP(i,M){ int t,l,r; cin >> t >> l >> r; l--; r--; if(t == 0){ for(int j = l; j <= r; j++){ B[32+i][j] = 1; } res[32+i] = 0; }else{ for(int j = l; j <= r; j++){ B[32+i][j] = 1; } res[32+i] = 1; } } int rank = linear_equation(B,res,res2); if(rank == -1) cout << 0 << endl; else{ LL ans = 1; REP(i,N-rank){ ans = ans * 2 % MOD; } cout << ans << endl; } }