#include #include #include #include #include template inline bool chmin(T &lhs, const U &rhs) { if (lhs > rhs) { lhs = rhs; return true; } return false; } template inline bool chmax(T &lhs, const U &rhs) { if (lhs < rhs) { lhs = rhs; return true; } return false; } // [l, r) from l to r struct range { struct itr { int i; constexpr itr(int i_): i(i_) { } constexpr void operator ++ () { ++i; } constexpr int operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { } constexpr itr begin() const { return l; } constexpr itr end() const { return r; } }; // [l, r) from r to l struct revrange { struct itr { int i; constexpr itr(int i_): i(i_) { } constexpr void operator ++ () { --i; } constexpr int operator * () const { return i; } constexpr bool operator != (itr x) const { return i != x.i; } }; const itr l, r; constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { } constexpr itr begin() const { return r; } constexpr itr end() const { return l; } }; constexpr int digit = 30; constexpr int mod = 1000000007; void solve(std::vector> &matrix) { int H = matrix.size(); int W = matrix.front().size(); int cur = 0; for (int j: range(0, W)) { int idx = -1; for (int i: range(cur, H)) { if (matrix[i][j]) { idx = i; break; } } if (idx == -1) { continue; } matrix[cur].swap(matrix[idx]); for (int i: range(cur + 1, H)) { if (matrix[i][j]) { for (int k: range(0, W)) { matrix[i][k] = matrix[i][k] ^ matrix[cur][k]; } } } ++cur; } } int main() { int N, M, X; std::cin >> N >> M >> X; std::vector A(N); std::vector T(M), L(M), R(M); for (int &x: A) { std::cin >> x; } for (int i: range(0, M)) { std::cin >> T[i] >> L[i] >> R[i]; --L[i]; --R[i]; } std::vector> coeff(digit + M, std::vector(N + 1)); for (int i: range(0, digit)) { int bit = (1 << i); coeff[i][N] = ((bit & X) > 0); for (int j: range(0, N)) { coeff[i][j] = ((bit & A[j]) > 0); } } for (int i: range(0, M)) { coeff[digit + i][N] = (T[i] == 1); std::fill(coeff[digit + i].begin() + L[i], coeff[digit + i].begin() + R[i] + 1, true); } solve(coeff); int rank = 0; for (const auto &vec: coeff) { if (std::count(vec.cbegin(), vec.cend() - 1, true) > 0) { ++rank; } } if (rank + 1 < coeff.size() && coeff[rank].back()) { std::cout << "0\n"; return 0; } int pow = N - rank; long long ans = 1, cur = 2; while (pow > 0) { if (pow & 1) { ans = (ans * cur) % mod; } cur = (cur * cur) % mod; pow >>= 1; } std::cout << ans << '\n'; return 0; }