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(int i = (a); i < (b); i++)
                                #define RFOR(i,a,b) for(int i = (a) - 1; i>=(b);i--)
                                #define rep(i,n) FOR(i,0,n)
                                #define PB push_back
                                #define SZ(a) (int)a.size()
                                #define ALL(a) a.begin(), a.end()
                                #define FILL(a, value) memset(a, value, sizeof(a))
                                #define IOS ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0);
                                 
                                 
                                typedef   long long LL ;
                                typedef  vector<int > VI ;
                                typedef vector<LL > VL;
                                typedef pair<int,int > PII;
                                typedef pair<LL,LL> PLL;
                                 
                                const LL LINF = (LL)1e18 +47;
                                const int INF =  (int)1e9 + 47 ;
                                const int MOD =(int)1e9 + 7 ;
                                const int modulo = 998244353;
                                const int nax =  (int)(1e6) + 10;
                                const double EPS = 1e-7;
                                const int MAXN = 3 * (int)1e6 + 10; 
                                const LL p = 47; 
         
         vector<int > g[nax];
         vector<int > g1[nax]; 
         int timer = 0;
         int tin[nax];
         int tout[nax]; 
         void dfs_keshi(int v = 0)
         {
            tin[v] = timer++;
            for(auto to : g1[v])
            {
              dfs_keshi(to); 
            }
            tout[v] = timer++; 
         }
         bool upper(int a, int b )
         {
           return tin[a] <=tin[b] && tout[a] >=tout[b];
         }
         set<PII> s; 
         int ans = 1; 
         void dfs(int v = 0)
         {
            if(SZ(g[v]) == 0)
            {
              ans = max(ans, SZ(s)); 
            }
            for(auto to : g[v])
            {

              auto it = s.lower_bound({tin[to],-1});
             
              int op = 1; 
              PII x ;
              if(it !=s.begin()){
              it--; 
              x = *it;
              if(it->second >= tout[to])
              {
                  s.insert({tin[to],tout[to]}); 
                  s.erase(it); 
                  op =2 ;
              } 
              }
              else if(it !=s.end())
              {
                if(tout[to] >= it->second)
                {
                  op = -1;
                }
              } 
              if(op == 1)
              {
                s.insert({tin[to],tout[to]});
              }
//              cout << SZ(s) << '\n';
              dfs(to);
              if(op == 2 )
              {
                s.erase({tin[to],tout[to]});
                s.insert(x); 
              }
              if(op == 1)
              {
                s.erase({tin[to],tout[to]});
              }
            }
         }
         int main() {
             IOS;
             #ifndef ONLINE_JUDGE
             freopen("input.txt", "r", stdin);                               
             freopen("output.txt", "w", stdout);
             #endif
             int tt;
             cin >> tt;
             FOR(test,1,tt + 1)
             {
             int n;
             cin >> n ;
          

             rep(i,n - 1){
              int x;
              cin >> x;
              --x;
              g[x].PB(i + 1);
             }
             rep(i,n - 1)
             {
              int x;
              cin >> x; 
              --x; 
              g1[x].PB(i + 1); 
             }
             dfs_keshi();
             s.insert({tin[0],tout[0]}); 
             dfs(); 
             cout << ans << endl;;
             FOR(i,0,n)
             {
              g[i].clear(); 
              g1[i].clear(); 

             }
             ans = 1; 
             timer = 0;
             s.clear(); 

           }

            

         }