Problem: Soroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1.

Soroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to prepare a Codeforces round. To celebrate this fortunate event, they decided to make a memorial graph on n vertices.

They add an edge between vertices u and v in the memorial graph if both of the following conditions hold: 

  * One of u or v is the ancestor of the other in Soroush's tree. 
  * Neither of u or v is the ancestor of the other in Keshi's tree. 



Here vertex u is considered ancestor of vertex v, if u lies on the path from 1 (the root) to the v.

Popping out of nowhere, Mashtali tried to find the maximum clique in the memorial graph for no reason. He failed because the graph was too big. 

Help Mashtali by finding the size of the maximum clique in the memorial graph.

As a reminder, clique is a subset of vertices of the graph, each two of which are connected by an edge.

Input

The first line contains an integer t (1≤ t≤ 3 ⋅ 10^5) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer n (2≤ n≤ 3 ⋅ 10^5).

The second line of each test case contains n-1 integers a_2, …, a_n (1 ≤ a_i < i), a_i being the parent of the vertex i in Soroush's tree.

The third line of each test case contains n-1 integers b_2, …, b_n (1 ≤ b_i < i), b_i being the parent of the vertex i in Keshi's tree.

It is guaranteed that the given graphs are trees.

It is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.

Output

For each test case print a single integer — the size of the maximum clique in the memorial graph.

Example

Input


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


Output


1
4
1
3

Note

In the first and third test cases, you can pick any vertex.

In the second test case, one of the maximum cliques is \{2, 3, 4, 5\}.

In the fourth test case, one of the maximum cliques is \{3, 4, 6\}.

Solution (in CPP):

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

#define FOR(i, a, b) for(__typeof(b) i = (a); i < (b); ++i)
#define dbg(x) cout << #x << " = " << x << '\n';
#define SOLVE int t; cin >> t; while(t--) solve()
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

// #define int long long

typedef int32_t i32;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// struct SegmentTree{
//     int n;
//     vi t;
//     SegmentTree(int n): n(n), t(2*n) {}
//     void update(int l, int r, int x){
//         for(l += n, r += n; l < r; l >>= 1, r >>= 1){
//             if(l & 1) t[l++] += x;
//             if(r & 1) t[--r] += x;
//         }
//     }
//     int query(int i){
//         int res = 0;
//         for(i += n; i > 0; i >>= 1) res += t[i];
//         return res;
//     }
// };

int t;
vi tin, tout;
vector<vi> g1, g2;

void dfs1(int v){
    tin[v] = t++;
    for(int u : g2[v]){
        dfs1(u);
    }
    tout[v] = t;
}

int mx;

void dfs2(int v, set<pii> &s){
    auto it = s.lower_bound({tin[v], 0});
    bool rem = true, add = true;
    int l = -1, r = -1;
    if(it != s.end()){
        l = it->first, r = it->second;
        if(tin[v] <= l && l < tout[v]){
            add = false;
        }
    }
    if(it != s.begin()){
        it = prev(it);
        l = it->first, r = it->second;
        if(l <= tin[v] && tin[v] < r){
            rem = true;
            // cout << l << ' ' << r << ' ' << tin[v] << '\n';
            s.erase(it);
        }
    }
    if(add) s.emplace(tin[v], tout[v]);
    // cout << v << ":\n";
    // for(auto [l, r] : s){
    //     cout << l << ' ' << r << '\n';
    // }
    for(int u : g1[v]){
        dfs2(u, s);
    }
    mx = max(mx, sz(s));
    if(add) s.erase({tin[v], tout[v]});
    if(rem){
        s.emplace(l, r);
    }
}

void solve(){
    int n; cin >> n; t = 0, mx = 1;
    tin.resize(n), tout.resize(n);
    g1.assign(n, vi());
    g2.assign(n, vi());
    FOR(i, 1, n){
        int j; cin >> j;
        j--;
        g1[j].push_back(i);
    }
    FOR(i, 1, n){
        int j; cin >> j;
        j--;
        g2[j].push_back(i);
    }
    dfs1(0);
    set<pii> s;
    dfs2(0, s);
    cout << mx << '\n';
}

i32 main(){
    // #ifndef LOCAL
    ios::sync_with_stdio(false); cin.tie(nullptr);
    // #endif
    SOLVE;
    // solve();
}