#include using namespace std; //typedef typedef unsigned int UINT; typedef unsigned long long ULL; typedef long long LL; typedef long double LD; typedef pair PLL; typedef tuple TLL3; typedef tuple TLL4; typedef set > setdownLL; #define PQ priority_queue typedef PQ, greater > pqupLL; //container utill #define ALL(v) (v).begin(),(v).end() #define CR [](auto element1, auto element2){return element1>element2;} #define LB lower_bound #define UP upper_bound #define PB push_back #define MP make_pair #define MT make_tuple //constant #define PI 3.141592653589793 const int MAX_ROW = 340; // to be set appropriately const int MAX_COL = 30+10; // to be set appropriately 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];} }; ostream& operator << (ostream& s, BitMatrix A) { s << endl; for (int i = 0; i < A.H; ++i) { for (int j = 0; j < A.W; ++j) { s << A[i][j] << ", "; } s << endl; } return s; } inline BitMatrix operator * (BitMatrix A, BitMatrix B) { BitMatrix R(A.H, B.W); BitMatrix tB(B.W, B.H); for (int i = 0; i < tB.H; ++i) for (int j = 0; j < tB.W; ++j) tB[i][j] = B[j][i]; for (int i = 0; i < R.H; ++i) for (int j = 0; j < R.W; ++j) R[i][j] = ((A[i] & tB[j]).count() & 1); return R; } inline BitMatrix pow(BitMatrix A, long long n) { BitMatrix R(A.H, A.H); for (int i = 0; i < A.H; ++i) R[i][i] = 1; while (n > 0) { if (n & 1) R = R * A; A = A * A; n >>= 1; } return R; } 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; } const int MOD = 1000000007; long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } int main() { //input LL N,M,X; cin >> N >> M >> X; LL A[N]; LL i,j; for(i=0; i> A[i]; } long long ty[M], l[M], r[M]; for(i=0; i> ty[i] >> l[i] >> r[i]; l[i]--, r[i]--; } //calc vector b; for(i=0; i<30; i++){ if(X%2==1){ b.PB(1); }else{ b.PB(0); } X/=2; } for(i=0; i c; LL rk=linear_equation(AA,b,c); LL ans; if(rk>=0){ ans=1; for(i=0; i