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> 
#include <memory>
using namespace std;
#define sf(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define ford(i,a,n) for(i=a;i<=n;i++)
#define forb(i,n,a) for(i=n;i>=a;i--)
#define mst(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define pb push_back
#define ddd cout<<"ddd"<<endl
#define maxn 1000010
#define pii pair<int,int>
#define inf 0x7fffffff
#define lson now<<1
#define rson now<<1|1
struct xds{
	int val,l,r,mid,lazy;
};
struct segment_tree{
	xds tree[maxn<<2];
	void pushup(int now)
	{
		tree[now].val=max(tree[lson].val,tree[rson].val);
	}
	void pushdown(int now)
	{
		tree[lson].val=tree[rson].val=tree[now].lazy;
		tree[lson].lazy=tree[now].lazy;
		tree[rson].lazy=tree[now].lazy;
		tree[now].lazy=-1;
	}
	void build(int L,int R,ll v,int now)//默认val为0 
	{
		tree[now].l=L;
		tree[now].r=R;
		tree[now].val=v;
		int mid=(L+R)>>1;
		tree[now].mid=mid;
		tree[now].lazy=-1;
		if(L==R)
		return;
		build(L,mid,v,lson);
		build(mid+1,R,v,rson);
	}
	int query(int l,int r,int now)
	{
		if(tree[now].l>=l&&tree[now].r<=r)
		{
			return tree[now].val;
		}
		if(tree[now].lazy!=-1)
		pushdown(now);
		int ans=0;
		if(tree[now].mid>=l)
		ans=query(l,r,lson);
		if(tree[now].mid<r)
		ans=max(ans,query(l,r,rson));
		pushup(now);
		return ans;
	}
	void change(int L,int R,int now,ll v)
	{
		if(tree[now].l>=L&&tree[now].r<=R)
		{
			tree[now].val=v;
			tree[now].lazy=v;
			return;
		}
		if(tree[now].lazy!=-1)
		pushdown(now);
		if(tree[now].mid>=L)
		change(L,R,lson,v);
		if(tree[now].mid<R)
		change(L,R,rson,v);
		pushup(now);
	}
};
struct shupou{
	segment_tree stree; //线段树 
	int first[maxn],nex[maxn],go[maxn],amount;//前向星 
	int fa[maxn],size[maxn],cnt,id[maxn];//树上信息 
	int val[maxn];
	void init(int n)
	{
		int i;
		stree.build(1,n,0,1);
		ford(i,1,n)
		first[i]=size[i]=0;
		amount=0;
		cnt=0;
	}
	void add(int u,int v)
	{
		go[++amount]=v;
		nex[amount]=first[u];
		first[u]=amount;
	}
	void dfs1(int now)
	{
		size[now]=1;
		int i;
		id[now]=++cnt;
		for(i=first[now];i;i=nex[i])
		{
			dfs1(go[i]);
			size[now]+=size[go[i]];
		}
	}
	int query(int x)
	{
	//	cout<<x<<" "<<id[x]<<" "<<id[x]+size[x]-1<<endl;
		return stree.query(id[x],id[x]+size[x]-1,1);
	}
	void changeson(int x,ll v)
	{
		stree.change(id[x],id[x]+size[x]-1,1,v);
	}
}sp; 
int first[maxn];
int nex[maxn];
int go[maxn];
int amount;
int q[maxn];
int l,r;
int f1[maxn],f2[maxn];
int maxx;
int pos[maxn];
void add(int u,int v)
{
	go[++amount]=v;
	nex[amount]=first[u];
	first[u]=amount;
}
int sum=0;
void dfs(int now)
{
	int nowl=l;
	int nowr=r;
	int i;
	int flag=0;
	int temp=sp.query(now);
	if(temp)
	{
		flag=1;
		sp.changeson(temp,0);
	}
	else
	sum++;
	sp.changeson(now,now);
	maxx=max(sum,maxx);
//	cout<<now<<endl;
	for(i=first[now];i;i=nex[i])
	{
	//	cout<<go[i]<<endl;
		dfs(go[i]);
	}
	sp.changeson(now,0);
	if(flag)
	sp.changeson(temp,temp);
	else
	sum--;
//	cout<<now<<" "<<l<<" "<<r<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//ddd;
	int test;
//	freopen("1.txt","r",stdin);
//	freopen("2.txt","w",stdout);
	cin>>test;
	while(test--)
	{
		int n;
		cin>>n;
		sp.init(n);
		int i;
		maxx=amount=0;
		ford(i,1,n)
		first[i]=q[i]=pos[i]=0;
		l=r=0;
		l=1;
		ford(i,2,n)
		{
			cin>>f1[i];
			add(f1[i],i);
		}
		ford(i,2,n)
		{
			cin>>f2[i];
			sp.add(f2[i],i);
		}
		sp.dfs1(1);
		dfs(1);
		cout<<maxx<<endl;
	}
}