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>
#define ls (o<<1)
#define rs (o<<1|1)
#define mid (pl+pr>>1)
using namespace std;
typedef long long ll;
const int N=3e5+5;
//int sg[N<<2|1],ad[N<<2|1];
int dfn[N],fan[N],siz[N],cl;
vector<int> e1[N],e2[N];
int ans,n;
set<int> st;
int read()
{
	int res=0,fl=0; char a=getchar();
	while(a<'0'||a>'9') fl|=a=='-',a=getchar();
	while(a>='0'&&a<='9') res=res*10+a-'0',a=getchar();
	return fl? -res:res;
}
//void pushr(int o,int pl,int pr,int k) {sg[o]+=k*(pr-pl+1),ad[o]+=k;}
//void push_down(int o,int pl,int pr) {if(ad[o]) pushr(ls,pl,mid,ad[o]),pushr(rs,mid+1,pr,ad[o]),ad[o]=0;}
//void update(int l,int r,int k,int o=1,int pl=1,int pr=n)
//{
//	if(l<=pl&&pr<=r) return pushr(o,pl,pr,k);
//	push_down(o,pl,pr);
//	if(l<=mid) update(l,r,k,ls,pl,mid);
//	if(r>mid) update(l,r,k,rs,mid+1,pr);
//	sg[o]=sg[ls]+sg[rs];
//}
//int query(int l,int r,int o=1,int pl=1,int pr=n)
//{
//	if(l<=pl&&pr<=r) return sg[o];
//	push_down(o,pl,pr);
//	int res=0;
//	if(l<=mid) res+=query(l,r,ls,pl,mid);
//	if(r>mid) res+=query(l,r,rs,mid+1,pr);
//	return res;
//}
void dfs(int x)
{
	dfn[x]=++cl,fan[cl]=x,siz[x]=1;
	for(int i=e2[x].size()-1;~i;i--)
		dfs(e2[x][i]),siz[x]+=siz[e2[x][i]];
}
void dfs2(int x)
{
	int er=-1,is=-1;
	if(st.empty()) is=x,st.insert(x);
	else
	{
		set<int>::iterator it=st.lower_bound(dfn[x]),it2;
		if(it!=st.begin()&&(it2=it,it2--,*it2+siz[fan[*it2]]>dfn[x])) er=*it2;
		if(it==st.end()||dfn[x]+siz[x]<=*it) is=dfn[x],st.insert(dfn[x]);
		if(er!=-1) st.erase(er);
	}
	ans=max(ans,(int)st.size());
	for(int i=e1[x].size()-1;~i;i--) dfs2(e1[x][i]);
	if(is>=0) st.erase(is);
	if(er>=0) st.insert(er);
}
int main()
{
	int i,j,li,t;
	for(t=read();t;t--)
	{
		n=read(),st.clear(),cl=0;
		for(i=1;i<=n;i++) e1[i].clear(),e2[i].clear();
		for(i=2;i<=n;i++) e1[read()].push_back(i);
		for(i=2;i<=n;i++) e2[read()].push_back(i);
		ans=0,dfs(1),dfs2(1),cout<<ans<<'\n';
	}
	return 0;
 }