#include <bits/stdc++.h>
using namespace std;
struct node {
  node *bit[2];
  int cnt = 0;
  int index = -1;
};
node *root;
void insert(string &s, int id) {
  node *cur = root;
  for (char x : s) {
    int ch = x - '0';
    if (!cur->bit[ch]) cur->bit[ch] = new node();
    cur = cur->bit[ch];
    cur->cnt++;
  }
  cur->index = id;
}
int already(string &s) {
  node *cur = root;
  for (char x : s) {
    int ch = x - '0';
    if (!cur->bit[ch])
      return -1;
    else if (cur->bit[ch]->cnt < 1)
      return -1;
    cur = cur->bit[ch];
  }
  return cur->index;
}
void remove(string &s) {
  node *cur = root;
  for (char x : s) {
    int ch = x - '0';
    cur = cur->bit[ch];
    cur->cnt--;
  }
  cur->index = -1;
}
void test_case() {
  root = new node();
  int n;
  cin >> n;
  int a[n];
  vector<bool> can(n, true);
  int both_zero = 0, both_one = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    a[i] = (s[0] - '0') * 2 + (s.back() - '0');
    if (s[0] != s.back()) {
      int index = already(s);
      if (index != -1) {
        can[index] = false;
        can[i] = false;
        remove(s);
      } else {
        reverse(s.begin(), s.end());
        insert(s, i);
      }
    } else {
      can[i] = false;
    }
  }
  vector<int> possible[2];
  vector<int> type(4, 0);
  for (int i = 0; i < n; i++) {
    if (can[i] == true) {
      possible[a[i] - 1].push_back(i + 1);
    } else {
      type[a[i]]++;
    }
  }
  vector<int> ans[2];
  vector<int> valid(2, true);
  for (int t = 0; t < 2; t++) {
    vector<int> cnt = type;
    vector<int> p[2];
    p[0] = possible[0];
    p[1] = possible[1];
    int last = t;
    for (int i = 0; i < n; i++) {
      bool found = false;
      for (int j = 0; j < 4; j++) {
        if (last == j / 2 && cnt[j] > 0) {
          cnt[j]--;
          found = true;
          last = j % 2;
          break;
        }
      }
      if (found) continue;
      if (!p[last].empty()) {
        p[last].pop_back();
        last = 1 - last;
        continue;
      }
      if (p[1 - last].empty()) {
        valid[t] = false;
        break;
      }
      ans[t].push_back(p[1 - last].back());
      p[1 - last].pop_back();
      last = 1 - last;
    }
  }
  if (valid[0] == false && valid[1] == false) {
    cout << "-1\n";
    return;
  }
  int id = 0;
  if (valid[0] == true && valid[1] == false) {
    id = 0;
  } else if (valid[0] == false && valid[1] == true) {
    id = 1;
  } else {
    if (ans[0].size() < ans[1].size())
      id = 0;
    else
      id = 1;
  }
  cout << (int)ans[id].size() << "\n";
  for (int i : ans[id]) cout << i << " ";
  cout << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) test_case();
}
