#include #define all(vec) vec.begin(), vec.end() #define pb push_back #define eb emplace_back using namespace std; using ll = long long; using P = pair; template using V = vector; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll MOD = 1e9 + 7; constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; template void chmin(T &a, T b) { a = min(a, b); } template void chmax(T &a, T b) { a = max(a, b); } void debug() { cerr << "ok" << endl; } template void vout(const vector &v) { for (int i = 0; i < v.size(); i++) { cout << v[i] << (i + 1 == v.size() ? '\n' : ' '); } } //from http://noshi91.hatenablog.com/entry/2019/03/31/174006 template class modint { using u64 = std::uint_fast64_t; public: u64 a; constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; } constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; } constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; } constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; } constexpr modint operator^(const u64 rhs) const noexcept { return modint(*this) ^= rhs; } constexpr modint &operator+=(const modint rhs) noexcept { a += rhs.a; if (a >= Modulus) { a -= Modulus; } return *this; } constexpr modint &operator-=(const modint rhs) noexcept { if (a < rhs.a) { a += Modulus; } a -= rhs.a; return *this; } constexpr modint &operator*=(const modint rhs) noexcept { a = a * rhs.a % Modulus; return *this; } constexpr modint &operator/=(modint rhs) noexcept { u64 exp = Modulus - 2; while (exp) { if (exp % 2) { *this *= rhs; } rhs *= rhs; exp /= 2; } return *this; } constexpr modint &operator^=(u64 exp) { modint rhs = modint(*this); a = 1; while (exp) { if (exp % 2) { *this *= rhs; } rhs *= rhs; exp /= 2; } return *this; } friend ostream &operator<<(ostream &os, const modint &x) { os << x.a; return os; } }; using mint = modint; const int maxH = 100040, maxW = 310; struct BitMatrix { bitset a[maxH]; int n, m; BitMatrix(int n_, int m_) : n(n_), m(m_) {} inline bitset &operator[](int i) { return a[i]; } }; //bitmatrix を掃き出し、rankを返す int GaussJordan(BitMatrix &a, bool extended) { int rank = 0; for (int j = 0; j < a.m; j++) { if (extended && j + 1 == a.m) break; int piv = -1; for (int i = rank; i < a.n; i++) { if (a[i][j]) { piv = i; break; } } if (piv == -1) continue; swap(a[rank], a[piv]); piv = rank; for (int i = 0; i < a.n; i++) { if (i == piv) continue; if (a[i][j]) { a[i] ^= a[piv]; } } rank++; } return rank; } //ax=b なるベクトルxを求め、自由度を返す O(HW^2) a:H*W b:H*1 x:W*1 int LinearEquation(BitMatrix a, vector b, vector &x) { BitMatrix na(a.n, a.m + 1); for (int i = 0; i < a.n; i++) { na[i] = a[i]; na[i][a.m] = b[i]; } int rank = GaussJordan(na, true); for (int i = rank; i < a.n; i++) { if (na[i][a.m]) return -1; } x.assign(a.m, 0); for (int i = 0; i < rank; i++) { x[i] = na[i][a.m]; } return a.m - rank; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, x; cin >> n >> m >> x; BitMatrix mat(m + 30, n); for (int i = 0; i < n; i++) { int a; cin >> a; for (int j = 0; j < 30; j++) { if ((a >> j) & 1) { mat[j][i] = 1; } } } V b(m + 30), xx; for (int i = 0; i < 30; i++) { if ((x >> i) & 1) { b[i] = 1; } } for (int i = 0; i < m; i++) { int t, l, r; cin >> t >> l >> r; --l; --r; b[i + 30] = t; for (int j = l; j <= r; j++) { mat[i + 30][j] = 1; } } int res = LinearEquation(mat, b, xx); if (res == -1) { cout << 0 << '\n'; return 0; } cout << (mint(2) ^ res) << '\n'; }