#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000 + 10;
int main() {
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  for (int now = 0; now < T; ++now) {
    static char str[MAXN];
    static int a[MAXN];
    static bitset<MAXN> sets, temp;
    static bitset<MAXN> p[MAXN], s[MAXN];
    sets = temp = 0;
    cin >> str;
    int n = strlen(str);
    for (int i = 0; str[i]; ++i) a[i] = str[i] - '0';
    int st = 0;
    for (int i = 0; i < MAXN; ++i) {
      int r = 0;
      for (int j = st; j < n; ++j) {
        a[j] += r * 10;
        r = a[j] & 1;
        a[j] >>= 1;
      }
      temp[i] = r;
      while (st < n && a[st] == 0) st++;
    }
    for (int i = 0; i < MAXN; ++i)
      if (temp[i]) {
        if (p[i] != 0) {
          sets ^= s[i];
          temp ^= p[i];
        } else {
          p[i] = temp;
          sets[now] = 1;
          s[i] = sets;
          cout << "0";
          break;
        }
      }
    if (temp == 0) {
      cout << sets.count() << ' ';
      for (int i = 0; i < T; ++i)
        if (sets[i]) cout << i << ' ';
    }
    cout << endl;
  }
}
