#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
using pii = pair<long long, long long>;
template <typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Prior = priority_queue<T>;
const long long INF = 1E18;
const long long mod = 1E9 + 7;
void solve() {
  long long n;
  cin >> n;
  vector<long long> v1(n), v2(n), cnt(n + 1);
  for (auto &x : v1) cin >> x;
  for (auto &x : v2) cin >> x;
  vector<pii> adj[n + 1];
  for (long long i = 0; i < n; ++i) {
    if (++cnt[v1[i]] > 2 or ++cnt[v2[i]] > 2) {
      cout << -1 << "\n";
      return;
    }
    adj[v1[i]].emplace_back(v2[i], i + 1),
        adj[v2[i]].emplace_back(-v1[i], i + 1);
  }
  vector<long long> vis(n + 1), ans;
  for (long long i = 1; i <= n; ++i) {
    long long now = i, lst = -1;
    vector<long long> pos, neg;
    while (!vis[now]) {
      vis[now] = 1;
      if (abs(adj[now][0].first) != lst) {
        if (adj[now][0].first > 0)
          pos.emplace_back(adj[now][0].second);
        else
          neg.emplace_back(adj[now][0].second);
        lst = now, now = abs(adj[now][0].first);
      } else {
        if (adj[now][1].first > 0)
          pos.emplace_back(adj[now][1].second);
        else
          neg.emplace_back(adj[now][1].second);
        lst = now, now = abs(adj[now][1].first);
      }
    }
    if (pos.size() <= neg.size()) {
      for (auto x : pos) ans.emplace_back(x);
    } else {
      for (auto x : neg) ans.emplace_back(x);
    }
  }
  cout << ans.size() << "\n";
  for (auto x : ans) cout << x << " ";
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
