#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005], CNT[200005], posa[200005], posb[200005], bel[200005],
    ans[200005], sz[200005], cnt[200005];
vector<int> v;
int main(int argc, char** argv) {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
      cnt[i] = 0, posa[i] = 0, posb[i] = 0, bel[i] = 0, sz[i] = 0, CNT[i] = 0,
      ans[i] = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      ++CNT[a[i]];
      if (!posa[a[i]])
        posa[a[i]] = i;
      else
        posb[a[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
      cin >> b[i];
      ++CNT[b[i]];
      if (!posa[b[i]])
        posa[b[i]] = i;
      else
        posb[b[i]] = i;
    }
    int flag = 1;
    for (int i = 1; i <= n; i++) flag &= CNT[i] == 2;
    if (!flag) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n; i++) {
      if (!bel[i]) {
        ans[i] = a[i];
        bel[i] = i;
        int now = i;
        while (1) {
          int x, p;
          if (ans[now] == a[now]) {
            x = b[now], p = posa[x];
            if (p == now) p = posb[x];
          } else {
            x = a[now], p = posa[x];
            if (p == now) p = posb[x];
          }
          if (bel[p]) break;
          bel[p] = i, ans[p] = x, now = p;
        }
      }
    }
    for (int i = 1; i <= n; i++) ++sz[bel[i]], cnt[bel[i]] += ans[i] == a[i];
    for (int i = 1; i <= n; i++) {
      if (sz[bel[i]] - cnt[bel[i]] > cnt[bel[i]])
        if (ans[i] == a[i])
          ans[i] = b[i];
        else
          ans[i] = a[i];
    }
    for (int i = 1; i <= n; i++) {
      if (ans[i] != a[i]) v.push_back(i);
    }
    cout << v.size() << "\n";
    for (auto x : v) cout << x << " ";
    puts("");
    v.clear();
  }
  return 0;
}
