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>
typedef long long int ll;
using namespace std;
#define sz 300009
#define mod 998244353
#define inf 1e18+5
#define f first
#define s second
#define pa pair<ll,ll>
#define eps 1e-9
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
std::vector<ll> v[sz],v1[sz];
ll tm1,arr[sz],brr[sz],par1[sz][20],crr[sz];
ll n,t[4*sz],lzy[4*sz],ans,dp[sz];
void kor(ll node,ll l,ll r)
{
  ll mid=(l+r)/2;
  t[2*node]+=(lzy[node]*(mid-l+1));
  t[2*node+1]+=lzy[node]*(r-mid);
  lzy[2*node]+=lzy[node];
  lzy[2*node+1]+=lzy[node];
  lzy[node]=0;
  return;
}
ll query(ll node,ll l,ll r,ll le,ll ri)
{
  if(l>ri || le>r)
    return 0;
  if(l>=le && r<=ri){
    return t[node];
  }
  kor(node,l,r);
  ll mid=(l+r)/2;
  ll a=query(2*node,l,mid,le,ri);
  ll b=query(2*node+1,mid+1,r,le,ri);
  return a+b;
}
void update(ll node,ll l,ll r,ll le,ll ri,ll val)
{
  if(l>ri || le>r)
    return;
  if(l>=le  && r<=ri)
  {
    t[node]+=(r-l+1)*val;
    lzy[node]+=val;
    return;
  }
  kor(node,l,r);
  ll mid=(l+r)/2;
  update(2*node,l,mid,le,ri,val);
  update(2*node+1,mid+1,r,le,ri,val);
  t[node]=t[2*node]+t[2*node+1];
  return;
}
void solve(ll node,ll par)
{
  par1[node][0]=par;
  for(int i=1;i<20;i++)
  {
    ll a=par1[node][i-1];
    par1[node][i]=par1[a][i-1];
  }
  arr[node]=++tm1;
  crr[tm1]=node;
  for(int i=0;i<v1[node].size();i++)
    solve(v1[node][i],node);
  brr[node]=tm1;
}
void solve1(ll node,ll par)
{
  ll lst=node;
  for(int i=19;i>=0;i--)
  {
   if(par1[lst][i]==0)
    continue;
  //if(node==3)
    //printf("%lld\n",par1[lst][i]);
  ll a=query(1,1,n,arr[par1[lst][i]],arr[par1[lst][i]]);
  if(a)
    lst=par1[lst][i];
  }
  dp[node]=dp[par];
  ll a1=0;
 // printf("%lld %lld\n",lst,node);
  if(lst!=node)
  {
    a1=1;
    update(1,1,n,arr[lst],brr[lst],-1);
   // printf("%lld %lld\n",query(1,1,n,1,7),node);
    update(1,1,n,arr[node],brr[node],1);
   // printf("%lld\n",query(1,1,n,2,2));
  }
  else
  {
    ll a=query(1,1,n,arr[node],brr[node]);
    if(!a)
    {
     dp[node]++;
     a1=2;
     update(1,1,n,arr[node],brr[node],1);
    }
   // printf("%lld\n",a);
    //printf("%lld\n",query(1,1,n,arr[node],brr[node]));
  }
 // printf("%lld\n",query(1,1,n,1,1));
  ans=max(ans,dp[node]);
  for(int i=0;i<v[node].size();i++)
    solve1(v[node][i],node);
  if(a1==1)
  {
    update(1,1,n,arr[lst],brr[lst],1);
    update(1,1,n,arr[node],brr[node],-1);
  //  printf("%lld\n",query(1,1,n,2,2));
  }
  if(a1==2)
    update(1,1,n,arr[node],brr[node],-1);
 // printf("%lld %lld\n",query(1,1,n,1,1),node);
}
int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);
  int test_case=1;
   scanf("%d",&test_case);
  for(int cs=1;cs<=test_case;cs++)
  {
  // ll n;
   scanf("%lld",&n);
   for(int i=2;i<=n;i++)
   {
    ll a;
    scanf("%lld",&a);
    v[a].push_back(i);
   }
   for(int i=2;i<=n;i++)
   {
    ll a;
    scanf("%lld",&a);
    v1[a].push_back(i);
   }
   ans=tm1=0;
   solve(1,0);
   solve1(1,0);
   printf("%lld\n",ans);
  // for(int i=1;i<=n;i++)
  //  printf("%lld %lld\n",arr[i],brr[i]);
   for(int i=1;i<=n;i++)
   {
    arr[i]=brr[i]=crr[i]=dp[i]=0;
    v[i].clear();
    v1[i].clear();
    for(int j=0;j<20;j++)
      par1[i][j]=0;
   }
   for(int i=1;i<=4*n;i++)
    lzy[i]=t[i]=0;
  }
  return 0;
}