#include <bits/stdc++.h>
using namespace std;
char st[4000010];
char tot_st[4000010];
int num[2];
int flag[2];
int tot = 0;
int out[4000010];
struct _bin {
  int st, fi, len, num;
} arr[200010];
int cmp(_bin a, _bin b) {
  if (a.len != b.len) return a.len < b.len;
  for (int i = 0; i < a.len; ++i) {
    if (tot_st[i + a.st] != tot_st[i + b.st])
      return tot_st[i + a.st] < tot_st[i + b.st];
  }
}
int fin(int len) {
  int ll = 0, rr = tot - 1;
  while (ll <= rr) {
    int mid = (ll + rr) / 2;
    if (arr[mid].len != len) {
      if (arr[mid].len > len)
        rr = mid - 1;
      else
        ll = mid + 1;
      continue;
    }
    int flag = 0;
    for (int i = 0; i < len; ++i)
      if (st[i] != tot_st[arr[mid].st + i]) {
        if (st[i] < tot_st[arr[mid].st + i])
          rr = mid - 1;
        else
          ll = mid + 1;
        flag = 1;
        break;
      }
    if (!flag) return 0;
  }
  return 1;
}
int check(int tmp) {
  for (int i = 0, j = arr[tmp].fi - 1; i < arr[tmp].len; ++i) {
    st[i] = tot_st[j--];
  }
  return fin(arr[tmp].len);
}
int mainn() {
  int n;
  scanf("%d", &n);
  num[0] = num[1] = 0;
  int _st = 0;
  tot = 0;
  flag[0] = flag[1] = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%s", st);
    int len = 0;
    while (st[len]) ++len;
    if (st[0] != st[len - 1]) {
      ++num[st[0] - '0'];
      arr[tot].st = _st;
      for (int j = 0; j < len; ++j) tot_st[_st++] = st[j] - '0';
      arr[tot].fi = _st;
      arr[tot].len = len;
      arr[tot].num = i + 1;
      tot++;
    } else
      flag[st[0] - '0'] = 1;
  }
  sort(arr, arr + tot, cmp);
  if (flag[0] == 1 && flag[1] == 1) {
    if (num[0] + num[1] == 0) {
      printf("-1\n");
      return 0;
    }
  }
  if (flag[0] == 1 && flag[1] == 0 && tot == 0) {
    printf("0\n\n");
    return 0;
  }
  if (flag[1] == 1 && flag[0] == 0 && tot == 0) {
    printf("0\n\n");
    return 0;
  }
  int diff = 0;
  if (tot % 2 == 0)
    diff = 0;
  else
    diff = 1;
  int goal = 0;
  if (num[0] < num[1]) goal = 1;
  int tmp = 0;
  int ans = 0;
  while (tmp < tot) {
    if (num[goal] - num[1 - goal] <= diff) {
      printf("%d\n", ans);
      for (int i = 0; i < ans; ++i) printf("%d ", out[i]);
      printf("\n");
      return 0;
    }
    if (tot_st[arr[tmp].st] == goal && check(tmp)) {
      num[goal] -= 1;
      num[1 - goal] += 1;
      out[ans++] = arr[tmp].num;
    }
    ++tmp;
  }
  printf("-1\n");
  return 0;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) mainn();
}
