#include #include #include using namespace std; #define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"< 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; } 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() { int N; cin >> N; vector a(N); for (int i = 0; i < N; ++i) cin >> a[i]; const int DIGIT = 61; BitMatrix A(DIGIT, N); for (int d = 0; d < DIGIT; ++d) { for (int i = 0; i < N; ++i) { if (a[i] & (1LL<