#include <bits/stdc++.h>
using namespace std;
vector<int> r1, r2;
vector<bool> pd;
vector<int> out;
vector<pair<int, int>> mp;
int le(int i, int cur) {
  if (cur == mp[i].first) return mp[i].second;
  return mp[i].first;
}
bool mak(int i, int p) {
  if (mp[i].first == -1)
    mp[i].first = p;
  else if (mp[i].second == -1)
    mp[i].second = p;
  else
    return true;
  return false;
}
class proc {
  struct Dt {
    int pos;
    bool fl;
  };
  int p;
  int c;
  vector<Dt> out_c;

 public:
  proc(int i) {
    p = i;
    c = 0;
    re();
    if (c > out_c.size() / 2) {
      for (auto& i : out_c)
        if (!i.fl) out.push_back(i.pos);
    } else
      for (auto& i : out_c)
        if (i.fl) out.push_back(i.pos);
  }

 private:
  void re() {
    if (pd[p]) return;
    pd[p] = 1;
    if (r1[p] == r2[p]) return;
    int x = le(r1[p], p);
    if (r1[p] == r1[x]) {
      ++c;
      swap(r1[x], r2[x]);
      out_c.push_back({x, 1});
    } else
      out_c.push_back({x, 0});
    p = x;
    re();
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    r1.resize(n);
    r2.resize(n);
    mp = vector<pair<int, int>>(n, {-1, -1});
    pd = vector<bool>(n, 0);
    out = vector<int>(0);
    for (int i = 0; i < n; ++i) {
      cin >> r1[i];
      --r1[i];
    }
    for (int i = 0; i < n; ++i) {
      cin >> r2[i];
      --r2[i];
    }
    for (int i = 0; i < n; ++i)
      if (mak(r1[i], i) || mak(r2[i], i)) goto badcase;
    for (int i = 0; i < n; ++i) proc lp(i);
    cout << out.size() << endl;
    for (auto i : out) cout << i + 1 << ' ';
    cout << endl;
    continue;
  badcase:
    cout << -1 << endl;
  }
}
