#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long> a, b, u, z, p, q;
vector<vector<long long> > g, c;
void dfs(int v, int t) {
  u[v] = 1;
  (t ? q : p).push_back(v);
  for (auto to : g[v]) {
    if (u[to]) continue;
    if (a[v] != a[to] && b[v] != b[to])
      dfs(to, t);
    else
      dfs(to, t ^ 1);
  }
}
void f() {
  cin >> n;
  a = b = vector<long long>(n);
  g = c = vector<vector<long long> >(n, vector<long long>());
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
    c[a[i]].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    --b[i];
    c[b[i]].push_back(i);
  }
  for (auto x : c) {
    if (x.size() != 2) {
      cout << -1 << "\n";
      return;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (c[i][0] == c[i][1]) continue;
    int x = c[i][0];
    int y = c[i][1];
    g[x].push_back(y);
    g[y].push_back(x);
  }
  z.clear();
  u.assign(n, 0);
  for (int i = 0; i < n; ++i) {
    if (u[i] || g[i].empty()) continue;
    p.clear();
    q.clear();
    dfs(i, 0);
    if (p.size() > q.size()) swap(p, q);
    for (auto x : p) z.push_back(x);
  }
  cout << z.size() << "\n";
  for (auto x : z) cout << x + 1 << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) f();
  return 0;
}
