#include using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; /* F_2 上の連立線形方程式 ref: https://qiita.com/drken/items/a14e9af0ca2d857b85c3 */ // 掃き出し法 // vector> a: 連立方程式 Ax=b の拡大係数行列 // return: a のランク int rowReduction(vector>& a, vector& where) { int row = a.size(), col = a.front().size(); int rank = 0; for (int c = 0; c < col; c++) { if (c == col - 1) break; int pivot = -1; for (int r = rank; r < row; r++) { if (a[r][c]) { pivot = r; break; } } if (pivot == -1) continue; swap(a[pivot], a[rank]); where.push_back(c); for (int r = 0; r < row; r++) { if (row != rank && a[r][c]) { // A[r]^=A[c] for (int i = 0; i < c; i++) a[r][i] = a[r][i] ^ a[rank][i]; } } rank++; } return rank; } // 連立線形方程式 Ax=b を解く // x0: 特殊解(b=0 の場合は自明解になる) // ker: Ax=0 の解空間の基底 // 一般解は x0 と解空間の基底の任意の線形結合で表される int linearEquation(vector> a, vector b, vector& x0, vector>& ker) { int row = a.size(), col = a.front().size(); vector> a2 = a; for (int i = 0; i < row; i++) a2[i].push_back(b[i]); vector where; int rank = rowReduction(a2, where); for (int r = rank; r < row; r++) { if (a2[r].back()) return -1; } if (rank == col && b == vector(col, false)) return -1; x0 = vector(col, false); for (int i = 0; i < rank; i++) x0[where[i]] = a2[i].back(); { // いわゆる noshi 基底 vector a3(row); for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { if (a[r][c]) { a3[r].push_back('1'); } else { a3[r].push_back('0'); } } reverse(a3[r].begin(), a3[r].end()); } vector basis; for (string e : a3) { for (string b : basis) { string d; for (int i = 0; i < col; i++) { if (b[i] == e[i]) { d.push_back('0'); } else { d.push_back('1'); } } e = min(e, d); } if (e != string(col, '0')) basis.push_back(e); } ker = vector>(basis.size(), vector(col, false)); for (int r = 0; r < (int)basis.size(); r++) { reverse(basis[r].begin(), basis[r].end()); for (int c = 0; c < col; c++) ker[r][c] = basis[r][c] == '1'; } } return rank; } int main() { int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) cin >> A[i]; const int L = 70; N = min(N, L); vector> a(L, vector(N)); for (int i = 0; i < N; i++) { for (int j = 0; j < L; j++) { a[j][i] = (A[i] >> j) & 1; } } vector x0; vector> xs; int rank = linearEquation(a, vector(N, false), x0, xs); if (rank >= 0 && xs.size() > 0) { vector ans, ans2; for (int i = 0; i < N; i++) { if (xs[0][i]) ans.push_back(i); } cout << ans.size() << endl; for (int x : ans) { cout << x + 1 << ' '; } cout << endl; } else { cout << -1 << endl; } }