#include <bits/stdc++.h>
using namespace std;
const int maxm = 4e5 + 5;
vector<int> g[2][maxm];
vector<int> temp[maxm];
vector<int> ans;
int head[maxm], nt[maxm], tail[maxm];
int a[2][maxm];
int mark[maxm];
int pre[maxm];
int cnt[maxm];
int n;
int ffind(int x) { return pre[x] == x ? x : pre[x] = ffind(pre[x]); }
void add(int x, int y) {
  x = ffind(x), y = ffind(y);
  if (x == y) return;
  pre[y] = x;
  cnt[x] += cnt[y];
  nt[tail[x]] = head[y];
  tail[x] = tail[y];
}
void cal(int x) {
  for (int i = head[x]; i; i = nt[i]) {
    if (i > n) {
      ans.push_back(i - n);
      mark[i - n] = 1;
    } else {
      mark[i] = 1;
    }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[0][i];
    for (int i = 1; i <= n; i++) cin >> a[1][i];
    map<int, int> tot;
    for (int i = 1; i <= n; i++) {
      tot[a[0][i]]++;
      tot[a[1][i]]++;
    }
    int ok = 1;
    for (auto i : tot) {
      if (i.second != 2) {
        ok = 0;
        break;
      }
    }
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 1; i <= n; i++) {
      g[0][i].clear();
      g[1][i].clear();
    }
    for (int i = 1; i <= n; i++) {
      g[0][a[0][i]].push_back(i);
      g[1][a[1][i]].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
      pre[i] = i;
      cnt[i] = 0;
      head[i] = i;
      tail[i] = i;
      nt[i] = 0;
      pre[i + n] = i + n;
      cnt[i + n] = 1;
      head[i + n] = i + n;
      tail[i + n] = i + n;
      nt[i + n] = 0;
    }
    for (int i = 1; i <= n; i++) {
      if (g[0][i].size() == 2) {
        int x = g[0][i][0], y = g[0][i][1];
        add(x, y + n);
        add(x + n, y);
      } else if (g[1][i].size() == 2) {
        int x = g[1][i][0], y = g[1][i][1];
        add(x, y + n);
        add(x + n, y);
      } else {
        int x = g[0][i][0], y = g[1][i][0];
        add(x, y);
        add(x + n, y + n);
      }
    }
    for (int i = 1; i <= n; i++) {
      if (ffind(i) == ffind(i + n)) {
        ok = 0;
        break;
      }
    }
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    ans.clear();
    for (int i = 1; i <= n; i++) {
      mark[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      if (mark[i]) continue;
      int x = ffind(i), y = ffind(i + n);
      if (cnt[x] < cnt[y]) {
        cal(x);
      } else {
        cal(y);
      }
    }
    cout << ans.size() << endl;
    for (auto i : ans) {
      cout << i << ' ';
    }
    cout << endl;
  }
  return 0;
}
