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 pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
#define G getchar()
int read()
{
	int x=0; bool flg=false; char ch=G;
	for (;!isdigit(ch);ch=G) if (ch=='-') flg=true;
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return flg?-x:x;
}
#undef G
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//typedef pair<int,int> P;
/*const int mod=;
inline int upd(const int &x){return x+(x>>31&mod);}
inline void add(int &x,const int &y){x=upd(x+y-mod);}
inline void iadd(int &x,const int &y){x=upd(x-y);}
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1) res=1LL*res*x%mod;
	return res;
}*/
#define rep(i,l,r) for (int i(l),_##i(r);i<=_##i;i++)
#define per(i,l,r) for (int i(r),_##i(l);i>=_##i;i--)
#define forall(x,y,e) for (const int &y: e[x])

int n;
vector<int> a[300010],b[300010];

int id[300010],idtot,siz[300010];

void dfs0(int x){
	id[x]=++idtot; siz[x]=1;
	forall(x,y,b) dfs0(y),siz[x]+=siz[y];
}

ll tri[300010];
ll t2[300010];

void add(int x,int w,ll *tri){
	for (;x<=n;x+=x&-x) tri[x]+=w;
}

int ask(int x,ll *tri){
	ll z=0;
	for (;x;x-=x&-x) z+=tri[x];
	return z;
}

int z,g;

void dfs1(int x){
	int w=0;
	if (ask(id[x]+siz[x]-1,t2)-ask(id[x]-1,t2)) w=-1;
	else{
		w=ask(id[x],tri);
		if (w){
			add(id[w],-w,tri); add(id[w]+siz[w],w,tri);
			//add(id[w],-1,t2);
			--z;
		}
		add(id[x],x,tri); add(id[x]+siz[x],-x,tri);
		add(id[x],1,t2);
		++z;
	}
	g=max(g,z);
	forall(x,y,a) dfs1(y);
	if (~w){
		add(id[x],-x,tri); add(id[x]+siz[x],x,tri);
		add(id[x],-1,t2);
		--z;
		if (w){
			add(id[w],w,tri); add(id[w]+siz[w],-w,tri);
			//add(id[w],1,t2);
			++z;
		}
	}
}

void solve(){
	n=read();
	rep(i,1,n) a[i].clear(),b[i].clear();
	rep(i,2,n) a[read()].pb(i);
	rep(i,2,n) b[read()].pb(i);
	idtot=0; dfs0(1);
	z=g=0; dfs1(1);
	printf("%d\n",g);
}

int main()
{
	for (int T=read();T--;) solve();
	return 0;
}