Problem: Cirno has prepared n arrays of length n each. Each array is a permutation of n integers from 1 to n. These arrays are special: for all 1 ≤ i ≤ n, if we take the i-th element of each array and form another array of length n with these elements, the resultant array is also a permutation of n integers from 1 to n. In the other words, if you put these n arrays under each other to form a matrix with n rows and n columns, this matrix is a [Latin square](https://en.wikipedia.org/wiki/Latin_square).

Afterwards, Cirno added additional n arrays, each array is a permutation of n integers from 1 to n. For all 1 ≤ i ≤ n, there exists at least one position 1 ≤ k ≤ n, such that for the i-th array and the (n + i)-th array, the k-th element of both arrays is the same. Notice that the arrays indexed from n + 1 to 2n don't have to form a Latin square. 

Also, Cirno made sure that for all 2n arrays, no two arrays are completely equal, i. e. for all pair of indices 1 ≤ i < j ≤ 2n, there exists at least one position 1 ≤ k ≤ n, such that the k-th elements of the i-th and j-th array are different.

Finally, Cirno arbitrarily changed the order of 2n arrays.

AquaMoon calls a subset of all 2n arrays of size n good if these arrays from a Latin square.

AquaMoon wants to know how many good subsets exist. Because this number may be particularly large, find it modulo 998 244 353. Also, she wants to find any good subset. Can you help her?

Input

The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases.

The first line of each test case contains a single integer n (5 ≤ n ≤ 500).

Then 2n lines followed. The i-th of these lines contains n integers, representing the i-th array.

It is guaranteed, that the sum of n over all test cases does not exceed 500.

Output

For each test case print two lines.

In the first line, print the number of good subsets by modulo 998 244 353.

In the second line, print n indices from 1 to 2n — indices of the n arrays that form a good subset (you can print them in any order). If there are several possible answers — print any of them.

Example

Input


3
7
1 2 3 4 5 6 7
2 3 4 5 6 7 1
3 4 5 6 7 1 2
4 5 6 7 1 2 3
5 6 7 1 2 3 4
6 7 1 2 3 4 5
7 1 2 3 4 5 6
1 2 3 4 5 7 6
1 3 4 5 6 7 2
1 4 5 6 7 3 2
1 5 6 7 4 2 3
1 6 7 5 2 3 4
1 7 6 2 3 4 5
1 7 2 3 4 5 6
5
4 5 1 2 3
3 5 2 4 1
1 2 3 4 5
5 2 4 1 3
3 4 5 1 2
2 3 4 5 1
1 3 5 2 4
4 1 3 5 2
2 4 1 3 5
5 1 2 3 4
6
2 3 4 5 6 1
3 1 2 6 4 5
6 1 2 3 4 5
5 6 1 3 2 4
4 3 6 5 2 1
5 6 1 2 3 4
4 5 6 1 2 3
3 4 5 6 1 2
1 2 3 4 5 6
2 5 4 1 6 3
3 2 5 4 1 6
1 4 3 6 5 2


Output


1
1 2 3 4 5 6 7
2
1 3 5 6 10
4
1 3 6 7 8 9

Note

In the first test case, the number of good subsets is 1. The only such subset is the set of arrays with indices 1, 2, 3, 4, 5, 6, 7.

In the second test case, the number of good subsets is 2. They are 1, 3, 5, 6, 10 or 2, 4, 7, 8, 9.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

const int MOD = 998244353;

using ll = long long;
#define SZ(v) ((int)v.size())
struct Edge {
  int to;
  ll f, c;
};

struct Graph {
  vector<Edge> edges;
  vector<vector<int>> G;
  int s, t;
  Graph(int n, int s, int t) : edges(), G(n), s(s), t(t) {}

  void addEdge(int a, int b, ll c1, ll c2 = 0) // If not directed, take c2=c1
  {
    G[a].push_back(SZ(edges));
    edges.push_back(Edge{b, 0, c1});
    G[b].push_back(SZ(edges));
    edges.push_back(Edge{a, 0, c2});
  }
};

struct Dinic : public Graph {
  vector<int> dis, ptr;
  Dinic(int n, int s, int t) : Graph(n, s, t) {}

  ll dfs(ll v, ll maxF) {
    if (!maxF or v == t)
      return maxF;
    for (; ptr[v] < SZ(G[v]); ++ptr[v]) {
      int k = G[v][ptr[v]];
      Edge &ed = edges[k];
      if (ed.c > ed.f and dis[ed.to] == dis[v] + 1)
        if (ll df = dfs(ed.to, min(maxF, ed.c - ed.f))) {
          ed.f += df;
          edges[k ^ 1].f -= df;
          return df;
        }
    }
    return 0;
  }

  ll flow(void) {
    int N = SZ(G);
    ll f(0);
    while (1) {
      dis.assign(N, -1);
      queue<int> q;
      q.push(s);
      dis[s] = 0;
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        if (u == t)
          break;
        for (auto k : G[u]) {
          Edge ed = edges[k];
          if (ed.c > ed.f and dis[ed.to] == -1) {
            dis[ed.to] = dis[u] + 1;
            q.push(ed.to);
          }
        }
      }
      if (dis[t] == -1)
        break;
      ptr.assign(N, 0);
      while (ll df = dfs(s, (1LL << 62)))
        f += df;
    }
    return f;
  }
};

// addVar creates new var, returns x, use x to access var, and ~x to access not
// var
struct twoSat {
  int nbSommets;
  vector<vector<int>> gr;
  vector<int> values; // 0 = false, 1 = true

  twoSat(int n = 0) : nbSommets(n), gr(2 * n) {}

  int addVar() {
    gr.emplace_back();
    gr.emplace_back();
    return nbSommets++;
  }

  void either(int f, int j) {
    f = max(2 * f, -1 - 2 * f);
    j = max(2 * j, -1 - 2 * j);
    gr[f].push_back(j ^ 1);
    gr[j].push_back(f ^ 1);
  }

  void setValue(int x) { either(x, x); }

  void atMostOne(const vector<int> &li) {
    if ((li).size() <= 1)
      return;
    int cur = ~li[0];
    for (int i = 2; i < (int)li.size(); ++i) {
      int nxt = addVar();
      either(cur, ~li[i]);
      either(cur, nxt);
      either(~li[i], nxt);
      cur = ~nxt;
    }
    either(cur, ~li[1]);
  }

  vector<int> val, comp, z;
  int time = 0;

  int dfs(int i) {
    int low = val[i] = ++time, x;
    z.push_back(i);
    for (int e : gr[i])
      if (!comp[e])
        low = min(low, val[e] ?: dfs(e));
    if (low == val[i])
      do {
        x = z.back();
        z.pop_back();
        comp[x] = low;
        if (values[x >> 1] == -1)
          values[x >> 1] = x & 1;
      } while (x != i);
    return val[i] = low;
  }

  bool solve() {
    values.assign(nbSommets, -1);
    val.assign(2 * nbSommets, 0);
    comp = val;
    for (int i = 0; i < 2 * nbSommets; ++i)
      if (!comp[i])
        dfs(i);
    for (int i = 0; i < nbSommets; ++i)
      if (comp[2 * i] == comp[2 * i + 1])
        return 0;
    return 1;
  }
};

void solve() {
  int lenPerms, nbPerms;
  cin >> lenPerms;
  nbPerms = lenPerms * 2;

  vector<vector<int>> perms(nbPerms);
  for (auto &v : perms) {
    v.resize(lenPerms);
    for (auto &w : v) {
      cin >> w;
      --w;
    }
  }

  vector<bool> alive(nbPerms, true);
  vector<int> latinSquare;
  vector<int> seen(lenPerms);

  for (int i = 0; i < lenPerms; ++i) {
    bool found = false;
    for (int iCol = 0; iCol < lenPerms; ++iCol) {
      seen.assign(lenPerms, -1);
      for (int iPerm = 0; iPerm < nbPerms; ++iPerm)
        if (alive[iPerm]) {
          if (seen[perms[iPerm][iCol]] == -2)
            continue;
          else if (seen[perms[iPerm][iCol]] != -1)
            seen[perms[iPerm][iCol]] = -2;
          else
            seen[perms[iPerm][iCol]] = iPerm;
        }
      for (int iVal = 0; iVal < lenPerms; ++iVal)
        if (seen[iVal] >= 0) {
          found = true;
          latinSquare.push_back(seen[iVal]);
          for (int iPerm = 0; iPerm < nbPerms; ++iPerm)
            if (alive[iPerm]) {
              bool bad = false;
              for (int j = 0; j < lenPerms; ++j)
                bad |= perms[iPerm][j] == perms[seen[iVal]][j];
              if (bad)
                alive[iPerm] = false;
            }
          break;
        }
      if (found)
        break;
    }
    if (found)
      continue;
    // exactly 2 each time
    twoSat ts(nbPerms);
    for (int iCol = 0; iCol < lenPerms; ++iCol) {
      seen.assign(lenPerms, -1);
      for (int iPerm = 0; iPerm < nbPerms; ++iPerm)
        if (alive[iPerm]) {
          int v = perms[iPerm][iCol];
          if (seen[v] != -1) {
            ts.either(~iPerm, ~seen[v]);
            ts.either(iPerm, seen[v]);
          }
          seen[v] = iPerm;
        }
    }

    assert(ts.solve());
    for (int i = 0; i < nbPerms; ++i)
      if (alive[i] and ts.values[i])
        latinSquare.push_back(i);
    break;
  }

  assert((int)latinSquare.size() == lenPerms);
  sort(latinSquare.begin(), latinSquare.end());
  vector<int> compLatin;
  for (int i = 0; i < nbPerms; ++i) {
    auto it = lower_bound(latinSquare.begin(), latinSquare.end(), i);
    if (it == latinSquare.end() or *it != i)
      compLatin.push_back(i);
  }
  assert((int)compLatin.size() == lenPerms);

  int s = nbPerms, t = s + 1;
  Dinic dic(nbPerms + 2, s, t);
  for (int i : latinSquare)
    dic.addEdge(s, i, 1);
  for (int i : compLatin)
    dic.addEdge(i, t, 1);
  for (int i : latinSquare)
    for (int j : compLatin) {
      bool bad = false;
      for (int k = 0; k < lenPerms; ++k)
        bad |= perms[i][k] == perms[j][k];
      if (bad)
        dic.addEdge(i, j, 1);
    }

  assert(dic.flow() == lenPerms);
  vector<int> other(nbPerms);

  vector<array<int, 2>> pairs;
  for (int i : latinSquare)
    for (int ed : dic.G[i])
      if (dic.edges[ed].f == 1) {
        pairs.push_back({i, dic.edges[ed].to});
        break;
      }
  assert((int)pairs.size() == lenPerms);
  set<vector<bool>> possibles;

  vector<vector<int>> toFlip(lenPerms);
  for (int i = 0; i < lenPerms; ++i)
    for (int j = 0; j < lenPerms; ++j)
      if (i != j) {
        bool bad = false;
        for (int k = 0; k < lenPerms; ++k)
          bad |= perms[pairs[i][1]][k] == perms[pairs[j][0]][k];
        if (bad)
          toFlip[i].push_back(j);
      }

  vector<vector<bool>> isBad(lenPerms, vector<bool>(lenPerms));
  for (int i = 0; i < lenPerms; ++i)
    for (int j = i + 1; j < lenPerms; ++j) {
      bool bad = false;
      for (int k = 0; k < lenPerms; ++k)
        bad |= perms[pairs[i][1]][k] == perms[pairs[j][1]][k];
      isBad[i][j] = isBad[j][i] = bad;
    }

  for (int flipStart = 0; flipStart < lenPerms; ++flipStart) {
    bool bad = false;
    vector<bool> flipped(lenPerms);
    queue<int> q;
    q.push(flipStart);
    flipped[flipStart] = true;
    while (!q.empty()) {
      int flipping = q.front();
      q.pop();
      for (int nxt : toFlip[flipping])
        if (!flipped[nxt]) {
          flipped[nxt] = true;
          q.push(nxt);
        }
    }
    for (int i = 0; i < lenPerms; ++i)
      for (int j = i + 1; j < lenPerms; ++j)
        if (flipped[i] and flipped[j] and isBad[i][j]) {
          bad = true;
          break;
        }
    if (!bad)
      possibles.insert(flipped);
  }
  for (int i : latinSquare)
    for (int j : latinSquare)
      if (i < j)
        for (int k = 0; k < lenPerms; ++k)
          assert(perms[i][k] != perms[j][k]);

  long long ret = 1;
  for (int i = 0; i < (int)possibles.size(); ++i)
    ret = ret * 2 % MOD;
  cout << ret << '\n';
  for (int i : latinSquare)
    cout << i + 1 << ' ';
  cout << '\n';
}

signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int nbTests;
  cin >> nbTests;
  for (int iTest(0); iTest < nbTests; ++iTest)
    solve();
}