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:
#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define LL long long
#define LD long double
#define Complex complex<double>
#define y1 ___y1
#define next ___next
#define left ___left
#define right ___right
#define pii pair<int, int>
#define pll pair<LL, LL>
#define pdd pair<double, double>
#define pldld pair<LD, LD>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<pii>
#define vll vector<pll>
#define PQ priority_queue
#define ffo fflush(stdout)
#define gch getchar()
#define e (int)(1e9 + 7)
#define MOD (int)(998244353)
#define e2 (double)2.71828182846
#define pi (double)3.14159265358979
#define ri(X) scanf("%d", &(X))
#define rii(X, Y) scanf("%d%d", &(X), &(Y))
#define riii(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define rl(X) scanf("%lld", &(X))
#define rll(X, Y) scanf("%lld%lld", &(X), &(Y))
#define rlll(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define printi(X) printf("%d", (int)(X))
#define printii(X, Y) printf("%d %d", (int)(X), (int)(Y))
#define printiii(X, Y, Z) printf("%d %d %d", (int)(X), (int)(Y), (int)(Z))
#define printl(X) printf("%lld", (LL)(X))
#define printll(X, Y) printf("%lld %lld", (LL)(X), (LL)(Y))
#define printlll(X, Y, Z) printf("%lld %lld %lld", (LL)(X), (LL)(Y), (LL)(Z))
#define enter printf("\n")
#define space printf(" ")
struct matrix {
    int sz;
    LL a[105][105];
    matrix& operator = (const matrix &T) {
        sz = T.sz;
        for (int i = 1; i <= sz; i++) {
            for (int j = 1; j <= sz; j++) {
                a[i][j] = T.a[i][j];
            }
        }
        return *this;
    }
    matrix operator + (const matrix &T) const {
        matrix ans;
        ans.sz = sz;
        for (int i = 1; i <= sz; i++) {
            for (int j = 1; j <= sz; j++) {
                ans.a[i][j] = a[i][j] + T.a[i][j];
                ans.a[i][j] %= e;
            }
        }
        return ans;
    }
    matrix operator * (const matrix &T) const {
        matrix ans;
        ans.sz = sz;
        for (int i = 1; i <= sz; i++) {
            for (int j = 1; j <= sz; j++) {
                ans.a[i][j] = 0;
                for (int k = 1; k <= sz; k++) {
                    ans.a[i][j] += a[i][k] * T.a[k][j];
                    ans.a[i][j] %= e;
                }
            }
        }
        return ans;
    }
    matrix I() {
        matrix ans;
        ans.sz = sz;
        for (int i = 1; i <= sz; i++) {
            for (int j = 1; j <= sz; j++) {
                if (i == j) ans.a[i][j] = 1;
                else ans.a[i][j] = 0;
            }
        }
        return ans;
    }
    matrix power(LL p) {
        if (p == 0) return I();
        if (p == 1) return *this;
        matrix tmp = power(p / 2);
        if (p % 2) tmp = tmp * tmp * (*this);
        else tmp = tmp * tmp;
        return tmp;
    }
    void print() {
        for (int i = 1; i <= sz; i++) {
            for (int j = 1; j <= sz; j++) {
                printf(j == sz? "%lld\n" : "%lld ", a[i][j]);
            }
        }
        return;
    }
};
struct polynomial {
    vector<Complex> v;
    int sz;
    polynomial operator * (const polynomial &T) const {
        polynomial ans;
        if (sz >= T.sz) {
            ans = *this;
            for (int i = 0; i < T.sz; i++) {
                ans.v[i] *= T.v[i];
            }
        }
        else {
            ans = T;
            for (int i = 0; i < sz; i++) {
                ans.v[i] *= v[i];
            }
        }
        return ans;
    }
};
polynomial FFT(polynomial a) {
    if (a.sz <= 1) return a;
    polynomial even, odd;
    even.sz = odd.sz = 0;
    for (int i = 0; i < a.sz; i += 2) {
        even.v.pb(a.v[i]);
        even.sz++;
    }
    for (int i = 1; i < a.sz; i += 2) {
        odd.v.pb(a.v[i]);
        odd.sz++;
    }
    polynomial Even = FFT(even);
    polynomial Odd = FFT(odd);
    polynomial ans;
    ans.sz = a.sz;
    for (int i = 0; i < ans.sz; i++) {
        ans.v.pb(0);
    }
    for (int i = 0; i < a.sz / 2; i++) {
        Complex w = polar(1.0, -2 * pi * i / a.sz) * Odd.v[i];
        ans.v[i] = Even.v[i] + w;
        ans.v[i + a.sz / 2] = Even.v[i] - w;
    }
    return ans;
}
polynomial IFFT(polynomial a) {
    for (int i = 0; i < a.sz; i++) {
        a.v[i] = conj(a.v[i]);
    }
    polynomial ans = FFT(a);
    for (int i = 0; i < a.sz; i++) {
        ans.v[i] = conj(ans.v[i]);
        ans.v[i] /= ans.sz;
    }
    return ans;
}
struct polygon {
    int n;
    pii a[1005];
    double area() {
        double d1 = 0, d2 = 0;
        for (int i = 0; i < n; i++) {
            d1 += a[i].x * a[(i + 1) % n].y;
            d2 += a[(i + 1) % n].x * a[i].y;
        }
        return (d1 - d2) / 2;
    }
    bool inside(pldld p) {
        int ct = 0;
        LD d;
        pldld p1 = a[0];
        for (int i = 1; i <= n; i++) {
            pldld p2 = a[i % n];
            if (p.y > min(p1.y, p2.y) && p.y <= max(p1.y, p2.y) && p.x <= max(p1.x, p2.x) && p1.y != p2.y) {
                d = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;
                if (p1.x == p2.x || p.x <= d) ct++;
            }
            p1 = p2;
        }
        return ct % 2;
    }
};
struct graph {
    #define SZ 1005
    int n;
    vi v[SZ];
    int vis[SZ], low[SZ], t;
    int indeg[SZ];
    stack<int> st;
    int top = 0;
    bool instack[SZ];
    int to[SZ];
    void tarjanDFS(int x) {
        vis[x] = low[x] = ++t;
        st.push(x);
        instack[x] = true;
        for (auto i : v[x]) {
            if (!vis[i]) tarjanDFS(i);
            if (instack[i]) { // still no SCC
                low[x] = min(low[x], low[i]);
            }
        }
        if (vis[x] == low[x]) { // form SCC
            int i;
            do {
                i = st.top();
                st.pop();
                instack[i] = false;
                to[i] = x;
            } while (i != x);
        }
    }
    void tarjan() {
        memset(vis, 0, sizeof(vis));
        t = 0;
        for (int i = 1; i <= n; i++) { //1 to n
            if (!vis[i]) tarjanDFS(i);
        }
        return;
    }
    void calIndeg() {
        for (int i = 1; i <= n; i++) { //1 to n
            for (auto j : v[i]) indeg[j]++;
        }
        return;
    }
};
struct segtree {
    int l, r, mid;
    LL val = 0, lazy = 0;
    segtree *lc, *rc;
    segtree(int L, int R) {
        l = L;
        r = R;
        mid = (l + r) / 2;
        if (l != r) {
            lc = new segtree(l, mid);
            rc = new segtree(mid + 1, r);
        }
    }
    void apply(LL X) {
        val += X;
        // val += X * (r - l + 1);
        lazy += X;
    }
    void push() {
        if (l == r) return;
        lc->apply(lazy);
        rc->apply(lazy);
        lazy = 0;
    }
    void update(int L, int R, LL X) {
        push();
        if (l == L && r == R) {
            apply(X);
            return;
        }
        else if (R <= mid) lc->update(L, R, X);
        else if (L >= mid + 1) rc->update(L, R, X);
        else {
            lc->update(L, mid, X);
            rc->update(mid + 1, R, X);
        }
        val = min(lc->val, rc->val);
        // val = lc->val + rc->val;
    }
    LL query(int L, int R) {
        push();
        if (l == L && r == R) return val;
        else if (R <= mid) return lc->query(L, R);
        else if (L >= mid + 1) return rc->query(L, R);
        else {
            return min(lc->query(L, mid), rc->query(mid + 1, R));
            // return lc->query(L, mid) + rc->query(mid + 1, R);
        }
    }
    //segroot = new segtree(0, n - 1)
} *segroot;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) {
    uniform_int_distribution<int> uni(l, r);
    return uni(rng);
}
vl fac, inv;
LL power(LL a, LL p) {
    LL ans = 1;
    while (p) {
        if (p & 1) ans = ans * a % MOD;
        p >>= 1;
        a = a * a % MOD;
    }
    return ans;
}
vl inverse(int n) {
    vl ans(n + 1);
    ans[0] = ans[1] = 1;
    for (int i = 2; i <= n; i++) {
        ans[i] = ans[MOD % i] * (MOD - MOD / i) % MOD;
    }
    return ans;
}
vl factorial(int n) {
    vl ans(n + 1);
    ans[0] = ans[1] = 1;
    for (int i = 2; i <= n; i++) {
        ans[i] = ans[i - 1] * i % MOD;
    }
    return ans;
}
vl factorialInverse(int n) {
    vl inv = inverse(n);
    vl ans(n + 1);
    ans[0] = ans[1] = 1;
    for (int i = 2; i <= n; i++) {
        ans[i] = inv[i] * ans[i - 1] % MOD;
    }
    return ans;
}
LL ncr(int n, int r) {
    return fac[n] * inv[r] % MOD * inv[n - r] % MOD;
}
void calfacinv(int n) {
    fac = factorial(n);
    inv = factorialInverse(n);
    return;
}
struct node {
    int x, y;
    bool operator < (const node &T) const {
        return x < T.x;
    }
};

int T;
int n;
int a[1005][505];
vi v[505][505];
LL ans;
vi anss;
bool del[1005];

void solve(int CASE) {
    ri(n);
    ans = 1;
    anss.clear();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            v[i][j].clear();
        }
    }
    for (int i = 1; i <= 2 * n; i++) {
        del[i] = false;
        for (int j = 1; j <= n; j++) {
            ri(a[i][j]);
            v[j][a[i][j]].pb(i);
        }
    }
    while (anss.size() < n) {
        bool found = false;
        int last = 0;
        for (int i = 1; i <= 2 * n; i++) {
            if (del[i]) continue;
            last = i;
            for (int j = 1; j <= n; j++) {
                if (v[j][a[i][j]].size() == 1) {
                    found = true;
                    last = i;
                    break;
                }
            }
            if (found) break;
        }
        del[last] = true;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < v[i][a[last][i]].size(); j++) {
                if (v[i][a[last][i]][j] == last) {
                    v[i][a[last][i]].erase(v[i][a[last][i]].begin() + j);
                    break;
                }
            }
        }
        if (found) {
            anss.pb(last);
        }
        else {
            ans = ans * 2 % MOD;
            anss.pb(last);
        }
        for (int i = 1; i <= 2 * n; i++) {
            if (del[i]) continue;
            for (int j = 1; j <= n; j++) {
                if (a[i][j] == a[last][j]) {
                    del[i] = true;
                    for (int k = 1; k <= n; k++) {
                        for (int l = 0; l < v[k][a[i][k]].size(); l++) {
                            if (v[k][a[i][k]][l] == i) {
                                v[k][a[i][k]].erase(v[k][a[i][k]].begin() + l);
                                break;
                            }
                        }
                    }
                    break;
                }
            }
        }
    }
    printf("%lld\n", ans);
    sort(anss.begin(), anss.end());
    for (int i = 0; i < anss.size(); i++) {
        printf(i == anss.size() - 1? "%d\n":"%d ", anss[i]);
    }
    return;
}

int main() {
    T = 1;
    // ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    // cin >> T;
    ri(T); // delete if one test case
    // calfacinv(1e6);
    for (int _ = 1; _ <= T; _++) {
        solve(_);
    }
    return 0;
}