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>
#define pb push_back
#define x first
#define y second
#define pdd pair<double,double>
#define pii pair<int,int>
#define pll pair<LL,LL>
#define mp make_pair
#define LL long long
#define ULL unsigned long long
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
#define last Last
#define MXN 200005
int mod=998244353;
int f[1005];
int ok[1005];
int Find(int x){
    if(f[x]==x)return x;
    return f[x]=Find(f[x]);
}
struct GenMatch { // 1-base
    static const int MAXN = 1005;
    int V;
    bool el[MAXN][MAXN];
    int pr[MAXN];
    bool inq[MAXN],inp[MAXN],inb[MAXN];
    queue<int> qe;
    int st,ed;
    int nb;
    int bk[MAXN],djs[MAXN];
    int ans;
    void init(int _V) {
        V = _V;
        MEM(el); MEM(pr);
        MEM(inq); MEM(inp); MEM(inb);
        MEM(bk); MEM(djs);
        ans = 0;
    }
    void add_edge(int u, int v) {
        el[u][v] = el[v][u] = 1;
    }
    int lca(int u,int v) {
        memset(inp,0,sizeof(inp));
        while(1) {
            u = djs[u];
            inp[u] = true;
            if(u == st) break;
            u = bk[pr[u]];
        }
        while(1) {
            v = djs[v];
            if(inp[v]) return v;
            v = bk[pr[v]];
        }
        return v;
    }
    void upd(int u) {
        int v;
        while(djs[u] != nb) {
            v = pr[u];
            inb[djs[u]] = inb[djs[v]] = true;
            u = bk[v];
            if(djs[u] != nb) bk[u] = v;
        }
    }
    void blo(int u,int v) {
        nb = lca(u,v);
        memset(inb,0,sizeof(inb));
        upd(u); upd(v);
        if(djs[u] != nb) bk[u] = v;
        if(djs[v] != nb) bk[v] = u;
        for(int tu = 1; tu <= V; tu++)
        if(inb[djs[tu]]) {
            djs[tu] = nb;
            if(!inq[tu]){
                qe.push(tu);
                inq[tu] = 1;
            }
        }
    }
    void flow() {
        memset(inq,false,sizeof(inq));
        memset(bk,0,sizeof(bk));
        for(int i = 1; i <= V;i++)
        djs[i] = i;
        while(qe.size()) qe.pop();
        qe.push(st);
        inq[st] = 1;
        ed = 0;
        while(qe.size()) {
            int u = qe.front(); qe.pop();
            for(int v = 1; v <= V; v++)
            if(el[u][v] && (djs[u] != djs[v]) && (pr[u] !=
            v)) {
                if((v == st) || ((pr[v] > 0) && bk[pr[v]] >
                0))
                blo(u,v);
                else if(bk[v] == 0) {
                    bk[v] = u;
                    if(pr[v] > 0) {
                        if(!inq[pr[v]]) qe.push(pr[v]);
                        } else {
                        ed = v;
                        return;
                    }
                }
            }
        }
    }
    void aug() {
        int u,v,w;
        u = ed;
        while(u > 0) {
            v = bk[u];
            w = pr[v];
            pr[v] = u;
            pr[u] = v;
            u = w;
        }
    }
    int solve() {
        memset(pr,0,sizeof(pr));
        for(int u = 1; u <= V; u++)
        if(pr[u] == 0) {
            st = u;
            flow();
            if(ed > 0) {
                aug();
                ans ++;
            }
        }
        return ans;
    }
}gp;
struct Scc{
    int n, nScc, vst[MXN], bln[MXN];
    vector<int> E[MXN], rE[MXN], vec;
    void init(int _n){
        n = _n;
        for (int i=0; i<MXN; i++){
            E[i].clear();
            rE[i].clear();
        }
    }
    void add_edge(int u, int v){
        E[u].pb(v);
        rE[v].pb(u);
    }
    void DFS(int u){
        vst[u]=1;
        for (auto v : E[u])
        if (!vst[v]) DFS(v);
        vec.pb(u);
    }
    void rDFS(int u){
        vst[u] = 1;
        bln[u] = nScc;
        for (auto v : rE[u])
        if (!vst[v]) rDFS(v);
    }
    void solve(){
        nScc = 0;
        vec.clear();
        MEM(vst);
        for (int i=0; i<n; i++)
        if (!vst[i]) DFS(i);
        reverse(vec.begin(),vec.end());
        MEM(vst);
        for (auto v : vec){
            if (!vst[v]){
                rDFS(v);
                nScc++;
            }
        }
    }
}g,g2;
vector<int> v[1005];
int use[1005];
void solve(){
    int n;
    scanf("%d",&n);
    int a[1005][505];
    for(int i = 0;i<2*n;i++){
        v[i].clear();
        ok[i]=1;f[i]=i;
        use[i]=0; 
        for(int j=0;j<n;j++)scanf("%d",&a[i][j]);
    }
    gp.init(2*n);
    g.init(4*n);
    g2.init(2*n);
    for(int i = 0;i<2*n;i++){
        for(int j = i+1;j<2*n;j++){
            int ok=0;
            for(int k = 0;k<n;k++){
                if(a[i][k]==a[j][k]){
                    ok=1;
                   // printf("%d\n",k);
                    break;
                }
            }
            if(ok){
                gp.add_edge(i+1,j+1);
                g.add_edge(i,j+2*n);
                g.add_edge(j,i+2*n);
                v[i].pb(j);
                v[j].pb(i);
             //   printf("%d %d\n",i,j);
            }
        }
    }
    assert(gp.solve()==n);
    for(int i = 1;i<=2*n;i++){
        g.add_edge(i-1+2*n,gp.pr[i]-1);
    }
    g.solve();
    for(int i = 0;i<2*n;i++){
        if(g.bln[i]>g.bln[i+2*n])use[i]=1;
    }
    vector<pii> edge;
    for(int i=0;i<2*n;i++){
        if(!use[i]){
            for(auto it:v[i]){
                if(use[it]){
                   // printf("%d %d\n",gp.pr[i+1],it+1);
                    g2.add_edge(gp.pr[i+1]-1,it);
                    edge.pb(mp(gp.pr[i+1]-1,it));
                    int a=Find(it),b=Find(gp.pr[i+1]-1);
                    f[a]=b;
                }
            }
        }
    }
    g2.solve();
    int ok2[1005];
    fill(ok2,ok2+2*n+1,1);
    for(int i = 0;i<2*n;i++){
        if(!use[i]){
            for(auto it:v[i]){
                if(!use[it]){
                  //  printf("%d %d\n",i+1,it+1);
                    if(g2.bln[gp.pr[i+1]-1]==g2.bln[gp.pr[it+1]-1]){ok2[g2.bln[gp.pr[i+1]-1]]=0;
                   // printf("%d %d %d\n",gp.pr[i+1]-1,i+1,it+1);
                    }
                  //  int a=(gp.pr[i+1]-1),b=Find(gp.pr[it+1]-1);

                    //if(a==b)ok[a]=0;
                }
            }
        }
    }
    for(auto it:edge){
        if(g2.bln[it.x]!=g2.bln[it.y])ok2[g2.bln[it.x]]=0;
    }
    LL ans=1;
    for(int i = 0;i<2*n;i++){
        if(use[i]&&ok2[g2.bln[i]]){
            //printf("%d %d\n",i,g);
            ans=ans*2%mod;
            ok2[g2.bln[i]]=0;
        }
    }
    printf("%lld\n",ans);
    for(int i = 0;i<2*n;i++){
        if(use[i])printf("%d ",i+1);
    }
    printf("\n");
}
int main(){
    int t=1;
    scanf("%d",&t);
    while(t--){
        solve();
    }
    return 0;
}