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:
/*
Try eliminate useless posibilities as much as possible (a.k.a. pruning)
1) if there is a number with freq=1 in any column, the permutation having that number must be in the all valid latin square. Choose it, and delete all permutations that have conflict(s) with it
2) After that, you will have either empty set left, or a set of permutations where each existing numbers in each column will have freq = 2 (Pigeonhole principle)
3) Try elimimate useless possibilities further. If a permutation have conflicts with two permutations that shares the same number in some columns, that permutation will never be in a valid latin square, so delete it.
4) Now, we have a set of permutation where "each number in each column has freq = 2" and "If we picked a permutation here, then no number in any column will completely disappear".

Let's sort the remaining permutations (if there's any) by the first number
Consider looking this as a graph, where 
Each permutation is a node,
and there is an edge between permutations which has a conflict

Key Observation:
If one of the permutation with the same first number got eliminated (by choosing some permutation in the process), then another is forced to be picked.

Consider this logic, then this is like "Coloring a graph"
(but not exactly like bipartite graph, but the idea is similar)
If we color a node "1"(be in latin square), then all color of the nodes adjacent to it must be "2"(not in latin square),
But then, by our key observation, the node with the same first number of the color "2", must be colored "1" (or else we can't create a latin square)

If we consider each connected component independently, then
each component has only 0, 1, or 2 ways of valid coloring

Calculating the number ways by trial (simulation), and multiply to the answer.

Extra:
Can we simplify this further?
*/
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define ROF(i,a,b) for(int i=(a); i>=(b); --i)
#define pb push_back
#define eb emplace_back
#define SZ(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define make_unique(a) sort(all((a))), (a).erase(unique(all((a))),(a).end())
#define x first
#define y second
#define MP make_pair
#define MT make_tuple
#define debug(x) cout << #x << " = " << x << endl
#define debug2(x,y) FOR(i,1,y) cout << "##"; cout << #x << " = " << x << endl
#define mset(x,y) memset((x), (y), sizeof(x))

using namespace std;

typedef long long i64;
typedef long double ld;
typedef tuple<int,int,int> iii;
typedef pair<int,int> pii;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<i64>> vvl;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<i64,i64>> vpll;

int readInt(){ int a; scanf("%d",&a); return a; }
i64 readLong(){ i64 a; scanf("%lld",&a); return a;}
void readString(char *s){ scanf(" %s",s); }

string print(int a){ return to_string(a); }
string print(i64 a){ return to_string(a); }
string print(string a){ return a; }
template<typename T1, typename T2> string print(pair<T1,T2> x){ return "("+print(x.x)+","+print(x.y)+")"; }
template<typename T> string print(vector<T> v){ string ans = "[ "; for(T e : v) ans += print(e)+" "; ans += "]"; return ans; }
template<typename T> string print(T *a, T *b){ string ans = "[ "; while(a!=b) ans += print(*(a++))+" "; ans += "]"; return ans; }

const int mod = 998244353;
int add(int a, int b){ return ((a+=b)>=mod)?a-mod:a; }
int mul(int a, int b){ return a*1ll*b%mod; }
void adding(int &a, int b){ a = add(a, b); }
int pw(int a, int b){
	if(a==0) return 0;
	int ans = 1, res = a;
	for(int i = 1; i <= b; i<<=1, res=mul(res,res)){
		if(i&b) ans = mul(ans,res);
	}
	return ans;
}

// bruteforces to check pattern (during the contest)
// not really useful
void simulate(){
	vvi ans;
	vvi permute;
	vvi mark;
	int n = readInt();
	permute.resize(2*n);
	FOR(i, 0, 2*n-1){
		permute[i].resize(n);
		FOR(j, 0, n-1) permute[i][j] = readInt()-1;
	}
	vi choose(2*n, 0);
	FOR(i,n,2*n-1) choose[i] = 1;
	mark.resize(n);
	mark.assign(n, vi(n,0));
	do{
		FOR(i, 0, n-1) fill(all(mark[i]), 0);
		bool bad = false;
		FOR(i, 0, 2*n-1){
			if(choose[i]){
				FOR(j, 0, n-1){
					if(mark[j][permute[i][j]]){
						bad = true;
						break;
					}
					mark[j][permute[i][j]] = 1;
				}
			}
			if(bad) break;
		}
		if(bad) continue;
		ans.eb();
		FOR(i, 0, 2*n-1){
			if(choose[i]) ans.back().eb(i+1);
		}
	}while(next_permutation(all(choose)));
	printf("%d\n",SZ(ans));
	for(auto v : ans){
		FOR(i, 0, n-1) printf("%d ",v[i]);
		puts("");
	}
	ans.clear();
}

const int N = 505;
set<int> Count[N][N];
vvi per;
vi def_in; // definitely in answer
vvi g;
bool visit[N<<1];
queue<int> bfs;
vi freq[N][N];
int color[N<<1];
int n;

int play(int u){
	//printf("visit %d\n",u);
	bool finish = false;
	vi member;
	int ans = 0;
	bfs.push(u);
	visit[u] = true;

	FOR(i, 0, n-1)
		FOR(j, 0, n-1)
			freq[i][j].clear();

	while(!bfs.empty()){
		int u = bfs.front();
		//cout << u << ": ";
		bfs.pop();
		FOR(i, 0, n-1) freq[i][per[u][i]].eb(u);
		member.eb(u);
		make_unique(g[u]);
		//cout << print(g[u]) << endl;
		for(int e : g[u]){
			if(visit[e]) continue;
			visit[e] = true;
			bfs.push(e);
		}
	}
	// expect even number of nodes in a component
	//cout << "contains: " << print(member) << endl;
	assert(SZ(member)%2==0);
	int sz = SZ(member);
	int se = -1;
	FOR(i, 1, sz-1){
		if(per[member[i]][0] == per[member[0]][0]){
			se = member[i];
			break;
		}
	}
	int expect = sz/2;
	bool good = true;
	vi res;
	bfs.push(member[0]);
	color[member[0]] = 1;
	while(!bfs.empty()){
		int u = bfs.front();
		bfs.pop();
		if(color[u]==1){
			res.eb(u);
			for(int e : g[u]){
				if(color[e] && color[e] != 2){
					good = false;
					break;
				}
				if(color[e]) continue;
				color[e] = 2;
				bfs.push(e);
			}
		}else{
			FOR(i, 0, n-1){
				for(int e : freq[i][per[u][i]]){
					if(e != u){
						if(color[e] && color[e] == 2){
							good = false;
							break;
						}
						if(color[e]) continue;
						color[e] = 1;
						bfs.push(e);
					}
				}
				if(!good) break;
			}
		}
		if(!good) break;
	}
	//cout << "get: " << print(res) << endl;
	if(good && SZ(res)==expect){
		++ans;
		if(!finish){
			for(int e : res) def_in.eb(e);
			finish = true;
		}
	}
	good = true;
	res.clear();
	while(!bfs.empty()) bfs.pop();
	for(int e : member) color[e] = 0;
	color[se] = 1;
	bfs.push(se);
	while(!bfs.empty()){
		int u = bfs.front();
		bfs.pop();
		if(color[u]==1){
			res.eb(u);
			for(int e : g[u]){
				if(color[e] && color[e] != 2){
					good = false;
					break;
				}
				if(color[e]) continue;
				color[e] = 2;
				bfs.push(e);
			}
		}else{
			FOR(i, 0, n-1){
				for(int e : freq[i][per[u][i]]){
					if(e != u){
						if(color[e] && color[e] == 2){
							good = false;
							break;
						}
						if(color[e]) continue;
						color[e] = 1;
						bfs.push(e);
					}
				}
				if(!good) break;
			}
		}
		if(!good) break;
	}
	//cout << "get: " << print(res) << endl;
	if(good && SZ(res) == expect){
		++ans;
		if(!finish){
			for(int e : res) def_in.eb(e);
			finish = true;
		}
	}
	res.clear();
	while(!bfs.empty()) bfs.pop();
	for(int e : member) color[e] = 0;
	return ans;
}

void solve(){
	// clean
	per.clear();
	def_in.clear();
	g.clear();
	mset(visit, false);

	n = readInt();
	per.resize(2*n);
	per.assign(2*n, vi(n));
	FOR(i, 0, 2*n-1){
		FOR(j, 0, n-1){
			per[i][j]=readInt()-1;
			Count[j][per[i][j]].insert(i);
		}
	}
	while(1){
		int x = -1;
		FOR(i,0,n-1){
			FOR(j,0,n-1){
				if(SZ(Count[i][j]) == 1){
					// definite answer
					x = *(Count[i][j].begin());
					break;
				}
			}
			if(x != -1) break;
		}
		if(x == -1) break;
		//printf("definitely contains %d\n",x);
		set<int> to_del;
		def_in.eb(x);
		FOR(i, 0, n-1){
			for(int e : Count[i][per[x][i]]){
				to_del.insert(e);
			}
		}
		for(int e : to_del){
			//printf("delete %d\n",e);
			FOR(i, 0, n-1){
				Count[i][per[e][i]].erase(e);
			}
		}
	}
	//puts("finish first elimination");
	g.resize(2*n);
	FOR(i, 0, n-1){
		FOR(j, 0, n-1){
			vi temp;
			for(int e : Count[i][j]) temp.eb(e);
			Count[i][j].clear();
			FOR(k, 0, SZ(temp)-1){
				FOR(l, k+1, SZ(temp)-1){
					g[temp[k]].eb(temp[l]);
					g[temp[l]].eb(temp[k]);
				}
			}
		}
	}
	//puts("finish build graph");
	int ans = 1;
	FOR(i, 0, 2*n-1){
		if(g[i].empty() || visit[i]) continue;
		ans = mul(ans, play(i));
	}
	printf("%d\n",ans);
	sort(all(def_in));
	FOR(i, 0, n-1) printf("%d ",def_in[i]+1);
	puts("");
}

int main(){
	int t = 1;
	t = readInt();
	while(t--) solve();
	return 0;
}