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 maxn = 2010, P = 998244353;
int T, n, p[maxn][maxn], vis[maxn], lnk[maxn], ans[maxn], fa[maxn], sz[maxn];
int cnt, tim, tp, st[maxn], bel[maxn], dfn[maxn], low[maxn], type[maxn], ban[maxn][2];
bool chk[maxn][maxn];
vector<int> G[maxn], H[maxn];
mt19937 rnd(time(0));

int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}
 
void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    fa[x] = y, sz[y] += sz[x];
}

void tarjan(int v) {
    dfn[v] = low[v] = ++tim, st[++tp] = v;
    for (int u : H[v]) {
        if (!dfn[u]) tarjan(u), low[v] = min(low[v], low[u]);
        else if (!bel[u]) low[v] = min(low[v], dfn[u]);
    }
    if (dfn[v] == low[v]) {
        cnt++;
        for (int u = 0; u ^ v; ) u = st[tp--], bel[u] = cnt;
    }
}

int test(int v) {
    memset(vis, 0, sizeof(vis));
    queue<int> Q;
    Q.push(v), vis[v] = 1;
    while (!Q.empty()) {
        int x = Q.front(); Q.pop();
        for (int y : H[x]) if (!vis[y]) {
            Q.push(y), vis[y] = 1;
        }
    }
    for (int i = 1; i <= 2 * n; i++) if (i < lnk[i]) {
        if (vis[i] && vis[i + 2 * n]) return 0;
    }
    return 1;
}

int qp(int x, int y) {
    int z = 1;
    for (; y; y >>= 1, x = 1LL * x * x % P) {
        if (y & 1) z = 1LL * z * x % P;
    }
    return z;
}

int main() {
    scanf("%d", &T);
    while (T--) {
        scanf("%d", &n);
        for (int i = 1; i <= 2 * n; i++) {
            G[i].clear(), fa[i] = i, sz[i] = 1;
            for (int j = 1; j <= n; j++) scanf("%d", &p[i][j]);
        }
        for (int i = 1; i <= 4 * n; i++) {
            H[i].clear();
        }
        for (int i = 1; i <= 2 * n; i++) {
            for (int j = i + 1; j <= 2 * n; j++) {
                bool flag = 0;
                for (int k = 1; k <= n; k++) {
                    if (p[i][k] == p[j][k]) { flag = 1; break; }
                }
                chk[i][j] = chk[j][i] = flag;
                if (flag) G[i].push_back(j), G[j].push_back(i);
            }
        }
        function<int(int)> match = [&](int v) {
            shuffle(G[v].begin(), G[v].end(), rnd);
            for (int u : G[v]) if (!vis[u]) {
                vis[u] = 1;
                int z = lnk[u];
                lnk[u] = v, lnk[v] = u, lnk[z] = 0;
                if (!z || match(z)) return 1;
                lnk[u] = z, lnk[v] = 0, lnk[z] = u;
            }
            return 0;
        };
        memset(lnk, 0, sizeof(lnk));
        int num = 0;
        for (int i = 1; i <= 2 * n; i++) {
            memset(vis, 0, sizeof(vis));
            if (!lnk[i] && match(i)) num++;
        }
        while (num < n) {
            memset(lnk, 0, sizeof(lnk)), num = 0;
            for (int i = 1; i <= 2 * n; i++) {
                memset(vis, 0, sizeof(vis));
                if (!lnk[i] && match(i)) num++;
            }
        }
        for (int i = 1; i <= 2 * n; i++) if (i < lnk[i]) {
            for (int j = 1; j <= 2 * n; j++) if (j < lnk[j] && i ^ j) {
                if (chk[i][j]) H[i].push_back(j + 2 * n), H[j].push_back(i + 2 * n);
                if (chk[i][lnk[j]]) H[i].push_back(j), H[j + 2 * n].push_back(i + 2 * n);
                if (chk[lnk[i]][j]) H[i + 2 * n].push_back(j + 2 * n), H[j].push_back(i);
                if (chk[lnk[i]][lnk[j]]) H[i + 2 * n].push_back(j), H[j + 2 * n].push_back(i);
            }
        }
        tim = 0, memset(dfn, 0, sizeof(dfn));
        cnt = 0, memset(bel, 0, sizeof(bel));
        for (int i = 1; i <= 2 * n; i++) if (i < lnk[i]) {
            if (!dfn[i]) tarjan(i);
            if (!dfn[i + 2 * n]) tarjan(i + 2 * n);
        }
        for (int i = 1; i <= 2 * n; i++) if (i < lnk[i]) {
            type[i] = bel[i] < bel[i + 2 * n];
        }
        for (int i = 1; i <= 2 * n; i++) if (i < lnk[i]) {
            int foo = test(i), bar = test(i + 2 * n);
            ban[i][0] = !foo, ban[i][1] = !bar;
        }
        for (int i = 1; i <= 2 * n; i++) if (i < lnk[i]) {
            for (int j = 1; j <= 2 * n; j++) if (j < lnk[j] && i ^ j) {
                if ((!chk[i][j] && !(type[i] == 1 && type[j] == 1) && !ban[i][0] && !ban[j][0] ||
                    !chk[lnk[i]][lnk[j]] && !(type[i] == 0 && type[j] == 0) && !ban[i][1] && !ban[j][1])
                    && chk[i][lnk[j]] && chk[j][lnk[i]]) unite(i, j);
                if ((!chk[i][lnk[j]] && !(type[i] == 1 && type[j] == 0) && !ban[i][0] && !ban[j][1] ||
                    !chk[j][lnk[i]] && !(type[i] == 0 && type[j] == 1) && !ban[i][1] && !ban[j][0])
                    && chk[i][j] && chk[lnk[i]][lnk[j]]) unite(i, j);
            }
        }
        int cnt = 0;
        for (int i = 1; i <= 2 * n; i++) if (i < lnk[i]) {
            if (i == find(i) && sz[i] > 1) cnt++;
        }
        printf("%d\n", qp(2, cnt));
        for (int i = 1; i <= 2 * n; i++) if (i < lnk[i]) {
            if (type[i]) printf("%d ", i);
            else printf("%d ", lnk[i]);
        }
        putchar('\n');
    }
    return 0;
}