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:
//This amazing code is written by Primo.Jay.Pan From CUC

//Any questions please contact me
//QQ:898021802
//Mail: primojpan@gmail.com
//.    primojaypan@cuc.edu.cn


// CF1258C.cpp
// Created by Primo Jay Pan on 2021/5/26.
//While (true) RP++;


//head
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <csignal>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 0x3f3f3f3f
#define maxlongint 2147483647
#define maxint 32767
#define pi(double)acos(-1.0)
#define eps 1e-9
#define MID ((l+r)>>1)
#define lson (o<<1)
#define rson (o<<1|1)
//clear the array
#define cla(a) memset(a,0,sizeof(a))
#define clb(a) memset(a,INF,sizeof(a))
#define clc(a) memset(a,-1,sizeof(a))
#define maxn (int)((3e5)+10)
#pragma GCC optimize ("O2,unroll-loops")


using namespace std;


//BIT
inline int lowbit(int x)
{
	return x&(-x);
}

//var

vector<int> G1[maxn],G2[maxn];
int T,n;
set< pii > S;
int L[maxn],R[maxn];
int Clo=0;
int ans=0;
//main
inline void dfs1(int u)
{
	L[u]=Clo++;
	for (int i=0;i<G2[u].size();i++){
		int v=G2[u][i];
		dfs1(v);
	}
	R[u]=Clo;
	
}
inline int get(int u)
//-2表示u在S中有后代，不放u进去
//-1表示u在S中没有祖先
//otherwise返回祖先的id,并且删除
{
	set< pii >::iterator it=S.lower_bound(mp(L[u],u));
	if (it!=S.end() && R[it->second]<=R[u])
		return -2;//u在当前集合中有儿子，所以u不选
	if (it==S.begin())
		return -1;//为第一个元素，没有父元素
	--it;//迭代找父亲
	int Fa=it->second;
	if (R[u]>R[Fa])//不是祖先
		return -1;
	S.erase(it);
	return Fa;
}
inline void dfs2(int u)
{
	int Fa=get(u);
	if (Fa!=-2)
		S.insert(mp(L[u],u));
	ans=max(ans,(int)S.size());
	for (int i=0;i<G1[u].size();i++){
		int v=G1[u][i];
		dfs2(v);
	}
	if (Fa!=-2)
	{
		S.erase(mp(L[u],u));
		if (Fa!=-1)
			S.insert(mp(L[Fa],Fa));
	}
}
int main()
{
	
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>T;
	while (T--)
	{
		cin>>n;
		for (int i=1;i<=n;i++)
		{
			G1[i].clear();
			G2[i].clear();
		}
		for (int i=2;i<=n;i++)
		{
			int x;
			cin>>x;
			G1[x].push_back(i);
		}
		for (int i=2;i<=n;i++)
		{
			int x;
			cin>>x;
			G2[x].push_back(i);
		}
		Clo=1;
		dfs1(1);
		ans=0;
		dfs2(1);
		cout<<ans<<endl;
	}
	return 0;
}



/*
Test Data1:
Test Data2:
*/