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 unsigned long long ull;
typedef long long ll;
template<class T1,class T2,class T3>T1 ksm(T1 a,T2 b,T3 mod){T1 ans=1;while(b){if(b&1)ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
#ifndef ONLINE_JUDGE
template<class T>T __gcd(T a,T b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
#endif
#define inf INT_MAX
#define Max(x,y) x=max(x,y)
#define Min(x,y) x=min(x,y)
#define Out(t) printf("%s\n",(t)?"YES":"NO")
const double pi=acos(-1.);
const int def=300010;
const int mod=1000000007;
using namespace std;

struct segtree{
	#define lc (now<<1)
	#define rc (now<<1|1)

	ll lazy[def<<2];
	ll val[def<<2];
	int l=0,r=0;

	void init(int l,int r)
	{
		this->l=l;
		this->r=r;
		build(l,r);
	}

	void pushdown(int now)
	{
		if(~lazy[now]){
			if(lc<(def<<2))lazy[lc]=lazy[now];
			if(rc<(def<<2))lazy[rc]=lazy[now];
			val[now]=lazy[now];
			lazy[now]=-1;
		}
	}

	void pushup(int now)
	{	int mid=(l+r)/2;
		pushdown(lc);pushdown(rc);
		val[now]=max(val[lc],val[rc]);
	}

	void build(int l,int r,int now=1)
	{
		lazy[now]=-1;
		if(l==r)val[now]=0;
		else{
			int mid=(l+r)/2;
			build(l,mid,lc);
			build(mid+1,r,rc);
			pushup(now);
		}
	}

	void upd(int x,ll z){upd(l,r,x,x,z);}//单点修改
	void upd(int x,int y,ll z){upd(l,r,x,y,z);}//区间修改
	void upd(int l,int r,int x,int y,ll z,int now=1)//add or change
	{
		pushdown(now);
		if(x<=l&&r<=y)
			lazy[now]=z;
		else{
			int mid=(l+r)/2;
			if(x<=mid)
				upd(l,mid,x,y,z,lc);
			if(mid<y)
				upd(mid+1,r,x,y,z,rc);
			pushup(now);
		}
	}

	ll query(int x,int y){return query(l,r,x,y);}
	ll query(int l,int r,int x,int y,int now=1)
	{
		pushdown(now);
		if(x<=l&&r<=y)
			return val[now];
		else{
			int mid=(l+r)/2;
			ll ans=0;
			if(x<=mid)
				ans=max(ans,query(l,mid,x,y,lc));
			if(mid<y)
				ans=max(ans,query(mid+1,r,x,y,rc));
			return ans;
		}
	}
}tr;

vector<int>mp1[def],mp2[def];
int ans,l[def],r[def],cnt;

void dfs1(int now)
{
	l[now]=++cnt;
	for(auto i:mp2[now])
		dfs1(i);
	r[now]=cnt;
}

void dfs2(int now,int num)
{
	int ori=tr.query(l[now],r[now]);
	if(ori)
		tr.upd(l[ori],r[ori],0);
	else
		num++;
	tr.upd(l[now],r[now],now);
	for(auto i:mp1[now])
		dfs2(i,num);
	tr.upd(l[now],r[now],0);
	if(ori)
		tr.upd(l[ori],r[ori],ori);
	Max(ans,num);
}

int main()
{	int _=1,__=1,n,x;
	for(((1)?scanf("%d",&_):EOF);_;_--,__++){
		scanf("%d",&n);
		tr.init(1,n);
		for(int i=1;i<=n;i++){
			mp1[i].clear();
			mp2[i].clear();
		}
		for(int i=2;i<=n;i++){
			scanf("%d",&x);
			mp1[x].push_back(i);
		}
		for(int i=2;i<=n;i++){
			scanf("%d",&x);
			mp2[x].push_back(i);
		}
		cnt=ans=0;
		dfs1(1);
		dfs2(1,0);
		printf("%d\n",ans);
	}
	return 0;
}