#include <bits/stdc++.h>
const int MAXN = 200005;
using namespace std;
int n, a[2][MAXN], cid[MAXN], col[MAXN], cnt;
vector<pair<int, int> > occ[MAXN], es;
vector<int> G1[MAXN], G2[MAXN], mem[MAXN], cc;
void flood(int v, int root) {
  cid[v] = root;
  mem[root].push_back(v);
  for (int to : G1[v]) {
    if (cid[to] == -1) {
      flood(to, root);
    }
  }
}
pair<int, int> dfs(int v, int c) {
  col[v] = c;
  cc.push_back(v);
  pair<int, int> my =
      pair<int, int>((c == 0) * mem[v].size(), (c == 1) * mem[v].size());
  for (int to : G2[v]) {
    if (col[to] == -1) {
      pair<int, int> res = dfs(to, !c);
      if (res.first == -1) {
        return pair<int, int>(-1, -1);
      }
      my.first += res.first;
      my.second += res.second;
    } else if (col[to] == c) {
      return pair<int, int>(-1, -1);
    }
  }
  return my;
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cid[i] = col[i] = -1;
    cnt = 0;
    occ[i].clear();
    es.clear();
    G1[i].clear();
    G2[i].clear();
    mem[i].clear();
    cc.clear();
  }
  for (int id = 0; id <= 1; id++) {
    for (int i = 1; i <= n; i++) {
      cin >> a[id][i];
      occ[a[id][i]].push_back({id, i});
    }
  }
  for (int i = 1; i <= n; i++) {
    if (occ[i].size() != 2) {
      cout << "-1\n";
      return;
    }
    pair<int, int> p1 = occ[i][0], p2 = occ[i][1];
    if (p1.second == p2.second) {
      continue;
    }
    if (p1.first == p2.first) {
      es.push_back(pair<int, int>(p1.second, p2.second));
    } else {
      G1[p1.second].push_back(p2.second);
      G1[p2.second].push_back(p1.second);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (cid[i] == -1) {
      flood(i, ++cnt);
    }
  }
  for (pair<int, int> e : es) {
    G2[cid[e.first]].push_back(cid[e.second]);
    G2[cid[e.second]].push_back(cid[e.first]);
  }
  vector<int> ans;
  for (int i = 1; i <= cnt; i++) {
    if (col[i] == -1) {
      cc.clear();
      pair<int, int> p = dfs(i, 0);
      if (p.first == -1) {
        cout << "-1\n";
        return;
      }
      int take = (p.second < p.first);
      for (int x : cc) {
        if (col[x] == take) {
          for (int y : mem[x]) {
            ans.push_back(y);
          }
        }
      }
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " \n"[i + 1 == ans.size()];
  }
  if (ans.empty()) cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  cin >> tc;
  for (int i = 1; i <= tc; i++) {
    solve();
  }
  return 0;
}
