#include<bits/stdc++.h>usingnamespacestd;constintinf=(int)1e5+5;constintgreen=0,red=1,white=2;classTree{public:intn;vector<vector<int>>adj,dp;stringstr;// dp[i][d] is the answer when the highest node is i and it has
// color d.
Tree(intn){this->n=n;adj.resize(n);dp.resize(n,vector<int>(3,inf));}voiddfs(intsrc,intpar){// Start with no children.
if(str[src]=='P'){dp[src][green]=0;}if(str[src]=='S'){dp[src][red]=0;}if(str[src]=='C'){dp[src][white]=0;}for(autochild:adj[src]){if(child==par){continue;}dfs(child,src);vector<int>ndp(3,inf);for(intd:{green,red,white}){for(intnow:{green,red,white}){// Delete the edge between them.
ndp[d]=min(ndp[d],1+dp[src][d]+dp[child][now]);// Keep the edge between them.
intnxt=-1;if(d==white){nxt=now;}elseif(now==white){nxt=d;}else{if(d==now){nxt=d;}}if(nxt==-1){continue;}ndp[nxt]=min(ndp[nxt],dp[src][d]+dp[child][now]);}}swap(dp[src],ndp);}}};voidsolve(){intn;cin>>n;Treet(n);for(inti=1;i<n;i++){intp;cin>>p;p--;t.adj[i].push_back(p);t.adj[p].push_back(i);}cin>>t.str;t.dfs(0,-1);auto&dp=t.dp;cout<<min({dp[0][green],dp[0][red],dp[0][white]})<<"\n";}intmain(){intt;cin>>t;for(inti=0;i<t;i++){solve();}return0;}