#include #include using namespace std; const int N = 400, MOD = 1000000007; int n, m, x, v[N], z, r, cnt, ans; bitset a[N]; int main() { scanf("%d%d%d", &n, &m, &x); for (int i = 1; i <= n; ++i) scanf("%d", &v[i]); for (int i = 0; i < 30; ++i) { for (int j = 1; j <= n; ++j) { a[i + 1][j] = v[j] >> i & 1; } a[i + 1][n + 1] = x >> i & 1; } for (int i = 1, op, l, r; i <= m; ++i) { scanf("%d%d%d", &op, &l, &r); for (int j = 1; j <= n; ++j) { a[30 + i][j] = l <= j && j <= r; } a[30 + i][n + 1] = op; } r = 1, z = m + 30, cnt = 0; for (int c = 1; c <= n; ++c) { for (int i = r; i <= z; ++i) { if (a[i][c]) { swap(a[r], a[i]); break; } } if (a[r][c] == 0) { ++cnt; continue; } for (int i = r + 1; i <= z; ++i) { if (a[i][c]) { a[i] ^= a[r]; } } ++r; } if (r <= z) { for (int i = r; i <= z; ++i) { if (a[i][n + 1] != 0) { puts("0"); return 0; } } } ans = 1; for (int i = 1; i <= cnt; ++i) { ans = ans * 2LL % MOD; } printf("%d\n", ans); return 0; }