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:
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iomanip>
#include <list>
#include <stack>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
void eras(map<int,int> &m,int x)
{
    m[x]--;
    if (!m[x]) m.erase(x);
}
ostream& operator <<(ostream &out,__int128 x)
{
    out<<(ll)x;
    re out;
}
istream& operator >>(istream &in,__int128 &x)
{
    ll temp;
    in>>temp;
    x=temp;
    re in;
}
const int N=(int)3e5+100;
const int M=(int)1e7+10;
const int inf=(int)1e9+100;
const double eps=1e-9;
#define filename ""
    vector<int> v[N],g[N];
    int gtime=0;
    int tin[N],tout[N];
void dfs2(int x)
{
    tin[x]=gtime++;
    for(auto y:g[x])
    {
        dfs2(y);
    }
    tout[x]=gtime;
}
    set<pair<int,int> > s;
    int ma=0;
void dfs(int x)
{
    auto j=s.lower_bound({tin[x],-1});
    set<pair<int,int> > temp;
    if (j!=s.end())
    {
        if (!(tin[x]<=j->fi&&j->se<=tout[x]))
        {
            if (j!=s.begin())
            {
                j--;
                if (j->fi<=tin[x]&&tout[x]<=j->se)
                {
                    temp.in(*j);
                    s.er(j);
                }
            }
            s.insert({tin[x],tout[x]});
        }
    }
    else
    {
        if (j!=s.begin())
        {
            j--;
            if (j->fi<=tin[x]&&tout[x]<=j->se)
            {
                temp.in(*j);
                s.er(j);
            }
        }
        s.insert({tin[x],tout[x]});
    }
    ma=max(ma,(int)s.size());
    for(auto y:v[x])
    {
        dfs(y);
    }
    if (temp.size()) s.insert(*temp.begin());
    s.erase({tin[x],tout[x]});
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int T;
    cin>>T;
    while(T--)
    {
        ma=0;
        gtime=0;
        int n,i;
        cin>>n;
        fo(i,n-1)
        {
            int a;
            cin>>a;
            a--;
            v[a].pb(i+1);
        }
        fo(i,n-1)
        {
            int a;
            cin>>a;
            a--;
            g[a].pb(i+1);
        }
        dfs2(0);
        dfs(0);
        cout<<ma<<'\n';
        fo(i,n)
        {
            v[i].clear();
            g[i].clear();
        }
    }
}