//Zeinab's code (part 2) we R about to find out the bug :)
//IN THE NAME OF GOD
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#define PB push_back
using namespace std;

const int maxn = 5 * 1e5 + 20;
int n, q;
vector <int> adj[maxn];
char s[maxn];
int dis[maxn];
vector <int> fll[maxn];
int st[maxn], fin[maxn];
int tm = 0;
int dp [maxn][30];
int fi, se;
//bool ans[maxn];

void dfs (int v, int h){
    fll[h].PB (v);
    dis[v] = h;
    st[v] = tm++;
    for (int i = 0; i < (int)adj[v].size(); i++){
        int u = adj[v][i];
        dfs(u, h + 1);
    }
    fin[v] = tm++;
}

void full (){
    for (int i = 1; i <= n; i++){
        if (fll[i].empty())
            break;
        dp[fll[i][0]][s[fll[i][0]] - 'a']++;
        for(int j = 1; j < (int)fll[i].size(); j++){
            for (int l = 0; l < 26; l++)
                dp[fll[i][j]][l] = dp[fll[i][j - 1]][l];
            dp[fll[i][j]][s[fll[i][j]] - 'a']++;
        }
    }
}

bool cmp1 (int a, int b){
    return st[a] < st[b];
}

bool cmp2 (int a, int b){
    return fin[a] < fin[b];
}

void find (int v, int h){
    fi = lower_bound (fll[h].begin (), fll[h].end (), v, cmp1) - fll[h].begin ();
    se = upper_bound (fll[h].begin (), fll[h].end (), v, cmp2) - fll[h].begin ();
    //cerr<<fi<<'\t'<<se<<endl;
    if (se == 0)
        se = n + 1;
    else
        se -= 1;
    fi = fll[h][fi];
    se = fll[h][se];
    //cerr<<fi<<'\t'<<se<<endl;
}

bool check (int v, int h){
    find (v, h);
    int count = 0;
    for (int  i = 0; i < 26; i++){
        if((dp[se][i] - dp[fi][i] )% 2){
            if ( i != s[fi] - 'a')
            count++;
        }
        else if (i == s[fi] - 'a')
            count++;
    }
    if (count > 1)
        return 0;
    return 1;
}

int main (){
    scanf("%d%d",&n,&q);
    for(int  i = 1; i < n; i++){// zero based
        int p;
        scanf("%d",&p);
        p--;
        adj[p].PB (i);
    }
    scanf("%500010s", &s);
    dfs(0, 1);
    full();
    for (int i = 0; i < q; i++){
        int u, h;
        scanf("%d%d", &u, &h);
        u--;
        if ( dis[u] >= h || fll[h].empty()){
            printf("Yes\n");
            continue;
        }
        if (check (u, h)){
            printf("Yes\n");
        }
        else
            printf("No\n");
    }
    return 0;
}


///in his name ..:::12.6.94:::..
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int, int> pii;
const int maxn=5*1000*100+10;
int n,q,dp[maxn][30],str[maxn],fin[maxn],cnt,dis[maxn],INF = 1000*1000*1000;
vector <pii> Hi[2][maxn];
vector <int> ve[maxn];
char ch[maxn];

void make_dp(int u){
    dp[u][ch[u]-'a'] = 1;
    if(!Hi[0][dis[u]].size()) return;
    int id = (Hi[0][dis[u]].back()).S;
    for (int i = 0; i < 26; i++)
        dp[u][i] += dp[id][i];
}

void DFS (int u){
    str[u] = cnt++;
    make_dp(u);
    for (int i = 0; i < ve[u].size(); i++){
        dis[ve[u][i]] = dis[u] + 1;
        DFS (ve[u][i]);
    }
    fin[u] = cnt++;
    Hi[0][dis[u]].pb(pii(str[u],u));
    Hi[1][dis[u]].pb(pii(fin[u],u));
}

bool findi(int u, int h){
    int id = lower_bound (Hi[0][h].begin(), Hi[0][h].end(), pii(str[u],0)) - Hi[0][h].begin();
    int jd = upper_bound (Hi[1][h].begin(), Hi[1][h].end(), pii(fin[u],INF)) - Hi[1][h].begin() - 1;
    int fard = 0;
    for(int i = 0; i < 26 ; i++)
        if( ( dp[Hi[1][h][jd].S][i] - (id <= 0 ? 0 : dp[Hi[0][h][id-1].S][i]) ) % 2) fard++;
    if(fard > 1) return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    scanf("%d%d",&n,&q);
    for(int i = 1; i <= n - 1; i++){
        int par;
        scanf("%d",&par);
        par--;
        ve[par].pb(i);
    }
    scanf("%500001s",&ch);
    str[0] = 1; dis[0] = 1;
    DFS (0);
    for(int i = 0; i<q; i++){
        int u,h;
        scanf("%d%d",&u,&h);
        u--;
        if (dis[u] > h ) {
            printf("Yes\n");
            continue;
        }
        if(findi(u, h)) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

/*
6 5
1 1 1 3 3
zacccd
1 1
3 3
4 1
6 1
1 2

*/


///in his name ..:::12.6.94:::..
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int, int> pii;
const int maxn=5*1000*100+10;
int n,q,dp[maxn][30],str[maxn],fin[maxn],cnt,dis[maxn],INF = 1000*1000*1000;
vector <pii> Hi[2][maxn];
vector <int> ve[maxn];
string ch;

void make_dp(int u){
    dp[u][ch[u]-'a'] = 1;
    if(!Hi[0][dis[u]].size()) return;
    int id = (Hi[0][dis[u]].back()).S;
    for (int i = 0; i < 26; i++)
        dp[u][i] += dp[id][i];
}

void DFS (int u){
    str[u] = cnt++;
    make_dp(u);
    for (int i = 0; i < ve[u].size(); i++){
        dis[ve[u][i]] = dis[u] + 1;
        DFS (ve[u][i]);
    }
    fin[u] = cnt++;
    Hi[0][dis[u]].pb(pii(str[u],u));
    Hi[1][dis[u]].pb(pii(fin[u],u));
}

bool findi(int u, int h){
    int id = lower_bound (Hi[0][h].begin(), Hi[0][h].end(), pii(str[u],0)) - Hi[0][h].begin();
    int jd = upper_bound (Hi[1][h].begin(), Hi[1][h].end(), pii(fin[u],INF)) - Hi[1][h].begin() - 1;
    int fard = 0;
    for(int i = 0; i < 26 ; i++)
        if( ( dp[Hi[1][h][jd].S][i] - (id <= 0 ? 0 : dp[Hi[0][h][id-1].S][i]) ) % 2) fard++;
    if(fard > 1) return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    scanf("%d%d",&n,&q);
    for(int i = 1; i <= n - 1; i++){
        int par;
        scanf("%d",&par);
        par--;
        ve[par].pb(i);
    }
    cin>>ch;
    str[0] = 1; dis[0] = 1;
    DFS (0);
    for(int i = 0; i<q; i++){
        int u,h;
        scanf("%d%d",&u,&h);
        u--;
        if (dis[u] > h ) {
            printf("Yes\n");
            continue;
        }
        if(findi(u, h)) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

/*
6 5
1 1 1 3 3
zacccd
1 1
3 3
4 1
6 1
1 2

*/


//IN THE NAME OF GOD
//zeinab's code
#include <iostream>
#include <vector>
#include <algorithm>
#define PB push_back
using namespace std;

const int maxn = 5 * 1e5 + 10;
int n, q;
vector <int> adj[maxn];
string s;
vector <int> fll[maxn];
int st[maxn], fin[maxn];
int tm = 0;
int dp [maxn][26];
int fi, se,dis[maxn];
//bool ans[maxn];

void dfs (int v, int h){
    fll[h].PB (v);
    dis[v]=h;
    st[v] = tm++;
    for (int i = 0; i < (int)adj[v].size(); i++){
        int u = adj[v][i];

        dfs(u, h + 1);
    }
    fin[v] = tm++;
}

void full (){
    for (int i = 1; i <= n; i++){
        if (fll[i].empty())
            break;
        dp[fll[i][0]][s[fll[i][0]] - 'a']++;
        for(int j = 1; j < (int)fll[i].size(); j++){
            for (int l = 0; l < 26; l++)
                dp[fll[i][j]][l] = dp[fll[i][j - 1]][l];
            dp[fll[i][j]][s[fll[i][j]] - 'a']++;
        }
    }
}

bool cmp1 (int a, int b){
    return st[a] < st[b];
}

bool cmp2 (int a, int b){
    return fin[a] < fin[b];
}

void find (int v, int h){
    fi = lower_bound (fll[h].begin (), fll[h].end (), v, cmp1) - fll[h].begin ();
    se = upper_bound (fll[h].begin (), fll[h].end (), v, cmp2) - fll[h].begin ();
    //cerr<<fi<<'\t'<<se<<endl;
    if (se == 0)
        se = n + 1;
    else
        se -= 1;
    fi = fll[h][fi];
    se = fll[h][se];
    //cerr<<fi<<'\t'<<se<<endl;
}

bool check (int v, int h){
    find (v, h);
    int count = 0;
    for (int  i = 0; i < 26; i++){
        if((dp[se][i] - dp[fi][i] )% 2){
            if ( i != s[fi] - 'a')
            count++;
        }
        else if (i == s[fi] - 'a')
            count++;
    }
    if (count > 1)
        return 0;
    return 1;
}

int main (){
    cin>>n>>q;
    for(int  i = 1; i < n; i++){// zero based
        int p;
        cin>>p;
        p--;
        adj[p].PB (i);
    }
    cin>>s;
    dfs(0, 1);
    full();
    for (int i = 0; i < q; i++){
        int u, h;
        cin>>u>>h;
        u--;
        if(dis[u]>=h){cout<<"Yes\n"; continue;}
        if (check (u, h)){
            cout<<"Yes"<<endl;
            continue;
        }
        else
            cout<<"No"<<endl;
    }
    return 0;
}


///in his name ..:::12.6.94:::..
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int, int> pii;
const int maxn=5*1000*100+20;
int n,q,dp[maxn][30],str[maxn],fin[maxn],cnt,dis[maxn],INF = 1000*1000*1000;
vector <pii> Hi[3][maxn];
vector <int> ve[maxn];
char ch[maxn];

void make_dp(int u){
    dp[u][int(ch[u]-'a')] = 1;
    if(Hi[0][dis[u]].empty()) return;
    int id = (Hi[0][dis[u]].back()).S;
    for (int i = 0; i < 26; i++)
        dp[u][i] += dp[id][i];
}

void DFS (int u){
    str[u] = cnt++;
    make_dp(u);
    for (int i = 0; i < ve[u].size(); i++){
        dis[ve[u][i]] = dis[u] + 1;
        DFS (ve[u][i]);
    }
    fin[u] = cnt++;
    Hi[0][dis[u]].pb(pii(str[u],u));
    Hi[1][dis[u]].pb(pii(fin[u],u));
}

bool findi(int u, int h){
    int id = lower_bound (Hi[0][h].begin(), Hi[0][h].end(), pii(str[u],0)) - Hi[0][h].begin();
    int jd = upper_bound (Hi[1][h].begin(), Hi[1][h].end(), pii(fin[u],INF)) - Hi[1][h].begin() - 1;
    int fard = 0;
    if(jd < 0) return true;
    for(int i = 0; i < 26 ; i++)
        if( (dp[Hi[1][h][jd].S][i] - (id <= 0 ? 0 : dp[Hi[0][h][id-1].S][i]) ) % 2 == 1) fard++;
    if(fard > 1) return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    scanf("%d%d",&n,&q);
    for(int i = 1; i <= n - 1; i++){
        int par;
        scanf("%d",&par);
        par--;
        ve[par].pb(i);
    }
    scanf("%500010s",&ch);
    dis[0] = 1;
    DFS (0);
    for(int i = 0; i<q; i++){
        int u,h;
        scanf("%d%d",&u,&h);
        u--;
        if (dis[u] >= h || Hi[0][h].empty())
            printf("Yes\n");
        else if(findi(u, h))
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}

/*
6 5
1 1 1 3 3
zacccd
1 1
3 3
4 1
6 1
1 2

*/


///in his name ..:::12.6.94:::..
#include <iostream>
#include <algorithm>
#include <vector>
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int, int> pii;
const int maxn=5*1000*100+10;
int n,q,dp[maxn][30],str[maxn],fin[maxn],cnt,dis[maxn],INF = 1000*1000*1000;
vector <pii> Hi[2][maxn];
vector <int> ve[maxn];
char ch[maxn];

void make_dp(int u){
    dp[u][ch[u]-'a'] = 1;
    if(!Hi[0][dis[u]].size()) return;
    int id = (Hi[0][dis[u]].back()).S;
    for (int i = 0; i < 26; i++)
        dp[u][i] += dp[id][i];
}

void DFS (int u){
    str[u] = cnt++;
    make_dp(u);
    for (int i = 0; i < ve[u].size(); i++){
        dis[ve[u][i]] = dis[u] + 1;
        DFS (ve[u][i]);
    }
    fin[u] = cnt++;
    Hi[0][dis[u]].pb(pii(str[u],u));
    Hi[1][dis[u]].pb(pii(fin[u],u));
}

bool findi(int u, int h){
    int id = lower_bound (Hi[0][h].begin(), Hi[0][h].end(), pii(str[u],0)) - Hi[0][h].begin();
    int jd = upper_bound (Hi[1][h].begin(), Hi[1][h].end(), pii(fin[u],INF)) - Hi[1][h].begin() - 1;
    int fard = 0;
    for(int i = 0; i < 26 ; i++)
        if( ( dp[Hi[1][h][jd].S][i] - (id <= 0 ? 0 : dp[Hi[0][h][id-1].S][i]) ) % 2) fard++;
    if(fard > 1) return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>> n >> q;
    for(int i = 1; i <= n - 1; i++){
        int par;
        cin >> par; par--;
        ve[par].pb(i);
    }
    for (int i = 0; i < n; i++) cin >> ch[i];
    str[0] = 1; dis[0] = 1;
    DFS (0);
    for(int i = 0; i<q; i++){
        int u,h;
        cin >> u >> h; u--;
        if (dis[u] > h ) {cout << "Yes\n"; continue;}
        if(findi(u, h)) cout << "Yes\n";
        else cout << "No\n" ;
    }
    return 0;
}

/*
6 5
1 1 1 3 3
zacccd
1 1
3 3
4 1
6 1
1 2

*/


///in his name ..:::12.6.94:::..
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int, int> pii;
const int maxn=5*1000*100+10;
int n,q,dp[maxn][30],str[maxn],fin[maxn],cnt,dis[maxn],INF = 1000*1000*1000;
vector <pii> Hi[2][maxn];
vector <int> ve[maxn];
char ch[maxn];

void make_dp(int u){
    dp[u][ch[u]-'a'] = 1;
    if(!Hi[0][dis[u]].size()) return;
    int id = (Hi[0][dis[u]].back()).S;
    for (int i = 0; i < 26; i++)
        dp[u][i] += dp[id][i];
}

void DFS (int u){
    str[u] = cnt++;
    make_dp(u);
    for (int i = 0; i < ve[u].size(); i++){
        dis[ve[u][i]] = dis[u] + 1;
        DFS (ve[u][i]);
    }
    fin[u] = cnt++;
    Hi[0][dis[u]].pb(pii(str[u],u));
    Hi[1][dis[u]].pb(pii(fin[u],u));
}

bool findi(int u, int h){
    int id = lower_bound (Hi[0][h].begin(), Hi[0][h].end(), pii(str[u],0)) - Hi[0][h].begin();
    int jd = upper_bound (Hi[1][h].begin(), Hi[1][h].end(), pii(fin[u],INF)) - Hi[1][h].begin() - 1;
    int fard = 0;
    for(int i = 0; i < 26 ; i++)
        if( ( dp[Hi[1][h][jd].S][i] - (id <= 0 ? 0 : dp[Hi[0][h][id-1].S][i]) ) % 2) fard++;
    if(fard > 1) return false;
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    scanf("%d%d",&n,&q);
    for(int i = 1; i <= n - 1; i++){
        int par;
        scanf("%d",&par);
        par--;
        ve[par].pb(i);
    }
    scanf("%100001s",&ch);
    str[0] = 1; dis[0] = 1;
    DFS (0);
    for(int i = 0; i<q; i++){
        int u,h;
        scanf("%d%d",&u,&h);
        u--;
        if (dis[u] > h ) {
            printf("Yes\n");
            continue;
        }
        if(findi(u, h)) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

/*
6 5
1 1 1 3 3
zacccd
1 1
3 3
4 1
6 1
1 2

*/


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[500002][30];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
    return;
}

void in()
{
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        int aA;
        cin >> aA;
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        cin >> u >> h;
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            if(sll > 1) break;
        }
        if(sll > 1) cout<<"No\n";
            else cout <<"Yes\n"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[500002][27];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
    return;
}

void in()
{
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        int aA;
        cin >> aA;
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        cin >> u >> h;
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            if(sll > 1) break;
        }
        if(sll > 1) cout<<"No\n";
            else cout <<"Yes\n"<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[50002][30];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
}

void in()
{
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        int aA;
        cin >> aA;
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

void Solve_()
{
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        cin >> u >> h;
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            //if(sll > 1) break;
        }
        if(sll > 1) cout<<"No"<<endl;
            else cout <<"Yes"<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    Solve_();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[50002][30];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
}

void in()
{
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        int aA;
        cin >> aA;
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

void Solve_()
{
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        cin >> u >> h;
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            if(sll > 1) break;
        }
        if(sll > 1) cout<<"No"<<endl;
            else cout <<"Yes"<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    Solve_();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[500002][30];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
}

void in()
{
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        int aA;
        cin >> aA;
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

void Solve_()
{
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        cin >> u >> h;
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            if(sll > 1) break;
        }
        if(sll > 1) cout<<"No"<<endl;
            else cout <<"Yes"<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    Solve_();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[500002][30];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
}

void in()
{
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        int aA;
        cin >> aA;
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

void Solve_()
{
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        cin >> u >> h;
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            if(sll > 1) break;
        }
        if(sll > 1) cout<<"No\n";
            else cout <<"Yes\n"<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    Solve_();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[500002][27];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
    return;
}

void in()
{
    scanf("%d%d",&n,&m);
    for(int i = 1; i < n; i++)
    {
        int aA;
        cin >> aA;
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

int main()
{
    //ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        scanf("%d%d",&v,&h);
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            if(sll > 1) break;
        }
        if(sll > 1) printf("No\n");
            else printf("Yes\n");
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[500002][27];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
    return;
}

void in()
{
    scanf("%d%d",&n,&m);
    for(int i = 1; i < n; i++)
    {
        int aA;
        scanf("%d",&aA);
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

int main()
{
    //ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        scanf("%d%d",&u,&h);
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            if(sll > 1) break;
        }
        if(sll > 1) printf("No\n");
            else printf("Yes\n");
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[50002][30];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
}

void in()
{
    cin >> n >> m;
    for(int i = 1; i < n; i++)
    {
        int a;
        cin >> a;
        ke[a].push_back(i+1);
    }
    cin >> s;
}

void Solve_()
{
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        cin >> u >> h;
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu & 2)
                sll++;
            //if(sll > 1) break;
        }
        if(sll > 1) cout<<"No"<<endl;
            else cout <<"Yes"<<endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    Solve_();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, sl = 0;
string s;
vector <int> f[500002][27];
int vao[500002];
int ra[500002];
vector <int> ke[500002];

void DFS(int x, int h)
{
    f[h][s[x-1] - 'a'].push_back(++sl);
    vao[x] = sl;
    for(int i = 0; i < ke[x].size(); i++)
    {
        int v = ke[x][i];
        DFS(v, h+1);
    }
    ra[x] = ++sl;
    return;
}

void in()
{
    scanf("%d%d",&n,&m);
    for(int i = 1; i < n; i++)
    {
        int aA;
        cin >> aA;
        ke[aA].push_back(i+1);
    }
    cin >> s;
}

int main()
{
    //ios_base::sync_with_stdio(false);
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);
    in();
    DFS(1, 1);
    while(m--)
    {
        int u, h;
        scanf("%d%d",&u,&h);
        int sll = 0;
        for(int i = 0; i < 26; i++)
        {
            int luu = lower_bound(f[h][i].begin(), f[h][i].end(), ra[u]) - lower_bound(f[h][i].begin(), f[h][i].end(), vao[u]);
            if(luu % 2)
                sll++;
            if(sll > 1) break;
        }
        if(sll > 1) printf("No\n");
            else printf("Yes\n");
    }
    return 0;
}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////
ll n,m,p;
vector<ll> v[1234567],D[1234567];
ll depth[1234567];
ll par[1234567];
ll arr[28];
string str;
ll kth[22][523456];

void dfs(int ind,int dep){

    int i;
    depth[ind] = dep;
    D[dep].pb(ind);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,dep + 1);
        par[vv] = ind;
    }
}

void precomp(){

    int i,j;

    rep(i,2,n + 1)  kth[0][i] = par[i];

    rep(i,1,21){
        rep(j,1,n + 1)  {
            kth[i][j] = kth[i - 1][kth[i - 1][j]];
        }
    }
}

ll kthancestor(int ind,int dif){

    int i;

    rep(i,0,21){
        if((dif & (1<<i)))  {
            ind = kth[i][ind];
        }
    }

    return ind;
}

int main(){
    std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    cin>>n>>m;
    int i;
    rep(i,2,n + 1)  {
        cin>>p;
        v[p].pb(i);
    }

    cin>>str;
    dfs(1,1);
    precomp();

    int ver,dep;
    rep(i,0,m)  {

        memset(arr,0,sizeof(arr));

        cin>>ver>>dep;
        int dep_vertex = depth[ver];
        if(dep < dep_vertex){
            cout<<"Yes\n";
            continue;
        }
        int odd = 0;
        int j;
        rep(j,0,D[dep].size()){
            int c = D[dep][j];
            int ancestor = kthancestor(c,dep - dep_vertex);
            if(ancestor == ver){
                arr[str[c]]++;
                if(arr[str[c]] & 1) odd++;
                else odd--;
            }
        }

        if(odd == 1 || odd == 0)    {
            cout<<"Yes\n";
            continue;
        }
        else {
            cout<<"No\n";
        }

    }

return 0;

}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////

vector<ll> v[512345],A[512345][27];
ll n,m;
char str[512345];
int ticks = 0;
ll entry[512345],out[512345];

void dfs(int ind,int d){
    // cout<<ticks<<endl;
    entry[ind] = ++ticks;
    int i;

    A[d][str[ind - 1] - 'a'].pb(ticks);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,d + 1);
    }
    out[ind] = ticks;
}

int main(){
    // std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    // cin>>n>>m;
    scanf("%lld%lld",&n,&m);

    int i;
    int p;
    rep(i,2,n + 1)  {
        // cin>>p;
        scanf("%d",&p);
        v[p].pb(i);
    }
    // cin>>str;
    scanf("%s",str);
    dfs(1,1);
    int ver,dist;
    while(m--){
        // cin>>ver>>dist;
        scanf("%d%d",&ver,&dist);
        int L = entry[ver];
        int H = out[ver];
        int odd= 0;
        int k;
        rep(k,0,26){

            int hi = upper_bound(A[dist][k].begin(),A[dist][k].end(),H) - lower_bound(A[dist][k].begin(),A[dist][k].end(),L);
            // cout<<L<<"  "<<H<<"   "<<lo<<"  "<<hi<<endl;
            if((hi) & 1)    odd++;

        }

        if(odd < 2) {
            // cout<<"Yes\n";
            printf("Yes\n");
        }
        else {
            // cout<<"No\n";
            printf("No\n");
        }

    }

return 0;

}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////
ll n,m,p;
vector<ll> v[1234567],D[1234567];
ll depth[1234567];
ll par[1234567];
ll arr[28];
string str;
ll kth[22][523456];

void dfs(int ind,int dep){

    int i;
    depth[ind] = dep;
    D[dep].pb(ind);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,dep + 1);
        par[vv] = ind;
    }
}

void precomp(){

    int i,j;

    rep(i,2,n + 1)  kth[0][i] = par[i];

    rep(i,1,21){
        rep(j,1,n + 1)  {
            kth[i][j] = kth[i - 1][kth[i - 1][j]];
        }
    }
}

ll kthancestor(int ind,int dif){

    int i;

    rep(i,0,21){
        if((dif & (1<<i)))  {
            ind = kth[i][ind];
        }
    }

    return ind;
}

int main(){
    std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    cin>>n>>m;
    int i;
    rep(i,2,n + 1)  {
        cin>>p;
        v[p].pb(i);
    }

    cin>>str;
    dfs(1,1);
    precomp();

    int ver,dep;
    rep(i,0,m)  {

        cin>>ver>>dep;
        int dep_vertex = depth[ver];
        if(dep <= dep_vertex){
            cout<<"Yes\n";
            continue;
        }
        int odd = 0;
        int j;
        // cout<<"i = "<<i+1<<endl;
        rep(j,0,D[dep].size()){
            int c = D[dep][j];
            // cout<<"c = "<<c<<endl;
            int ancestor = kthancestor(c,dep - dep_vertex);
            if(ancestor == ver){
                arr[str[c - 1] - 'a']++;

                // cout<<"  "<<str[c - 1]<<endl;

            }
        }
        int hh;
        rep(hh,0,26)    {
            if(arr[hh] & 1) odd++;
            arr[hh] = 0;
        }

        if(odd == 1 || odd == 0)    {
            // cout<<"odd = "<<odd<<endl;
            cout<<"Yes\n";

        }
        else {
            // cout<<"odd = "<<odd<<endl;
            cout<<"No\n";
        }
        odd = 0;

    }

return 0;

}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////
ll n,m,p;
vector<ll> v[1234567],D[1234567];
ll depth[1234567];
ll par[1234567];
ll arr[28];
string str;
ll kth[22][523456];

void dfs(int ind,int dep){

    int i;
    depth[ind] = dep;
    D[dep].pb(ind);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,dep + 1);
        par[vv] = ind;
    }
}

void precomp(){

    int i,j;

    rep(i,2,n + 1)  kth[0][i] = par[i];

    rep(i,1,21){
        rep(j,1,n + 1)  {
            kth[i][j] = kth[i - 1][kth[i - 1][j]];
        }
    }
}

ll kthancestor(int ind,int dif){

    int i;

    rep(i,0,21){
        if((dif & (1<<i)))  {
            ind = kth[i][ind];
        }
    }

    return ind;
}

int main(){
    std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    cin>>n>>m;
    int i;
    rep(i,2,n + 1)  {
        cin>>p;
        v[p].pb(i);
    }

    cin>>str;
    dfs(1,1);
    precomp();

    int ver,dep;
    rep(i,0,m)  {

        cin>>ver>>dep;
        int dep_vertex = depth[ver];
        if(dep <= dep_vertex){
            cout<<"Yes\n";
            continue;
        }
        int odd = 0;
        int j;
        // cout<<"i = "<<i+1<<endl;
        rep(j,0,D[dep].size()){
            int c = D[dep][j];
            // cout<<"c = "<<c<<endl;
            if(c < ver) continue;
            int ancestor = kthancestor(c,dep - dep_vertex);
            if(ancestor == ver){
                arr[str[c - 1] - 'a']++;

                // cout<<"  "<<str[c - 1]<<endl;

            }
        }
        int hh;
        rep(hh,0,26)    {
            if(arr[hh] & 1) odd++;
            arr[hh] = 0;
        }

        if(odd == 1 || odd == 0)    {
            // cout<<"odd = "<<odd<<endl;
            cout<<"Yes\n";

        }
        else {
            // cout<<"odd = "<<odd<<endl;
            cout<<"No\n";
        }
        odd = 0;

    }

return 0;

}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////

vector<ll> v[512345],A[512345][27];
ll n,m;
char str[512345];
int ticks = 0;
ll entry[512345],out[512345];

void dfs(int ind,int d){
    // cout<<ticks<<endl;
    entry[ind] = ++ticks;
    int i;
    int x = str[ind - 1] - 'a';
    A[d][x].pb(ticks);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,d + 1);
    }
    out[ind] = ticks;
}

int main(){
    // std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    // cin>>n>>m;
    scanf("%lld%lld",&n,&m);

    int i;
    int p;
    rep(i,2,n + 1)  {
        // cin>>p;
        scanf("%d",&p);
        v[p].pb(i);
    }
    // cin>>str;
    scanf("%s",str);
    dfs(1,1);
    int ver,dist;
    while(m--){
        // cin>>ver>>dist;
        scanf("%d%d",&ver,&dist);
        int L = entry[ver];
        int H = out[ver];
        int odd= 0;
        int k;
        rep(k,0,26){

            int hi = upper_bound(A[dist][k].begin(),A[dist][k].end(),H) - lower_bound(A[dist][k].begin(),A[dist][k].end(),L);
            // cout<<L<<"  "<<H<<"   "<<lo<<"  "<<hi<<endl;
            if((hi) & 1)    odd++;

        }

        if(odd == 1 || odd == 0)    {
            // cout<<"Yes\n";
            printf("Yes\n");
        }
        else {
            // cout<<"No\n";
            printf("No\n");
        }

    }

return 0;

}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////

vector<int> v[512345],A[512345][27];
int n,m;
char str[512345];
int ticks = 0;
int entry[512345],out[512345];

void dfs(int ind,int d){
    // cout<<ticks<<endl;
    entry[ind] = ++ticks;
    int i;

    A[d][str[ind - 1] - 'a'].pb(ticks);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,d + 1);
    }
    out[ind] = ticks;
}

int main(){
    // std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    // cin>>n>>m;
    scanf("%d%d",&n,&m);

    int i;
    int p;
    rep(i,2,n + 1)  {
        // cin>>p;
        scanf("%d",&p);
        v[p].pb(i);
    }
    // cin>>str;
    scanf("%s",str);
    dfs(1,1);
    int ver,dist;
    while(m--){
        // cin>>ver>>dist;
        scanf("%d%d",&ver,&dist);
        int L = entry[ver];
        int H = out[ver];
        int odd= 0;
        int k;
        rep(k,0,26){

            int hi = upper_bound(A[dist][k].begin(),A[dist][k].end(),H) - lower_bound(A[dist][k].begin(),A[dist][k].end(),L);
            // cout<<L<<"  "<<H<<"   "<<lo<<"  "<<hi<<endl;
            if((hi) & 1)    odd++;

        }

        if(odd < 2) {
            // cout<<"Yes\n";
            printf("Yes\n");
        }
        else {
            // cout<<"No\n";
            printf("No\n");
        }

    }

return 0;

}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////

vector<ll> v[1234567],A[512345][27];
ll n,m;
char str[1234567];
int ticks = 0;
ll entry[1234567],out[1234567];

void dfs(int ind,int d){
    // cout<<ticks<<endl;
    entry[ind] = ++ticks;
    int i;
    int x = str[ind - 1] - 'a';
    A[d][x].pb(ticks);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,d + 1);
    }
    out[ind] = ++ticks;
}

int main(){
    // std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    // cin>>n>>m;
    scanf("%lld%lld",&n,&m);

    int i;
    int p;
    rep(i,2,n + 1)  {
        // cin>>p;
        scanf("%d",&p);
        v[p].pb(i);
    }
    // cin>>str;
    scanf("%s",str);
    dfs(1,1);
    int ver,dist;
    while(m--){
        // cin>>ver>>dist;
        scanf("%d%d",&ver,&dist);
        int L = entry[ver];
        int H = out[ver];
        int odd= 0;
        int k;
        rep(k,0,26){

            int lo = lower_bound(A[dist][k].begin(),A[dist][k].end(),L) - A[dist][k].begin();
            int hi = upper_bound(A[dist][k].begin(),A[dist][k].end(),H) - A[dist][k].begin();
            // cout<<L<<"  "<<H<<"   "<<lo<<"  "<<hi<<endl;
            if((hi - lo) & 1)   odd++;

        }

        if(odd == 1 || odd == 0)    {
            // cout<<"Yes\n";
            printf("Yes\n");
        }
        else {
            // cout<<"No\n";
            printf("No\n");
        }

    }

return 0;

}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////
ll n,m,p;
vector<ll> v[1234567],D[1234567];
ll depth[1234567];
ll par[1234567];
ll arr[28];
string str;
ll kth[22][523456];

void dfs(int ind,int dep){

    int i;
    depth[ind] = dep;
    D[dep].pb(ind);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,dep + 1);
        par[vv] = ind;
    }
}

void precomp(){

    int i,j;

    rep(i,2,n + 1)  kth[0][i] = par[i];

    rep(i,1,21){
        rep(j,1,n + 1)  {
            kth[i][j] = kth[i - 1][kth[i - 1][j]];
        }
    }
}

ll kthancestor(int ind,int dif){

    int i;

    rep(i,0,21){
        if((dif & (1<<i)))  {
            ind = kth[i][ind];
        }
    }

    return ind;
}

int main(){
    std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    cin>>n>>m;
    int i;
    rep(i,2,n + 1)  {
        cin>>p;
        v[p].pb(i);
    }

    cin>>str;
    dfs(1,1);
    precomp();

    int ver,dep;
    rep(i,0,m)  {

        memset(arr,0,sizeof(arr));

        cin>>ver>>dep;
        int dep_vertex = depth[ver];
        if(dep <= dep_vertex){
            cout<<"Yes\n";
            continue;
        }
        int odd = 0;
        int j;
        rep(j,0,D[dep].size()){
            int c = D[dep][j];
            int ancestor = kthancestor(c,dep - dep_vertex);
            if(ancestor == ver){
                arr[str[c]]++;
                if(arr[str[c]] & 1) odd++;
                else odd--;
            }
        }

        if(odd == 1 || odd == 0)    {
            cout<<"Yes\n";
            continue;
        }
        else {
            cout<<"No\n";
        }

    }

return 0;

}


    #include<bits/stdc++.h>
    #include<string>
    using namespace std;
    #define         mp(x, y) make_pair(x, y)
    #define         SIZE(c) (int)c.size()
    #define         pb(x) push_back(x)
    //#define       map<char,int>::iterator it;
    #define         ff first
    #define         ss second
    #define         ll long long
    #define         ld long double
    #define         pii pair< int, int >
    #define         psi pair< string, int >
    #define         p(n) printf("%lld\n",n)
    #define         p64(n) printf("%I64d\n",n)
    #define         s(n) scanf("%lld",&n)
    #define         s64(n) scanf("%I64d",&n)
    #define         rep(i,a,b) for(i=a;i<b;i++)
    #define         repp(i,a,b) for(i = b - 1;i >= a;i--)
    #define         MOD (1000000007LL)

    ///////////////////////////////////////////////////////

vector<ll> v[1234567],A[512345][27];
ll n,m;
string str;
int ticks = 0;
ll entry[1234567],out[1234567];

void dfs(int ind,int d){
    // cout<<ticks<<endl;
    entry[ind] = ++ticks;
    int i;
    int x = str[ind - 1] - 'a';
    A[d][x].pb(ticks);

    rep(i,0,v[ind].size()){
        int vv = v[ind][i];
        dfs(vv,d + 1);
    }
    out[ind] = ++ticks;
}

int main(){
    std::ios::sync_with_stdio(false);
    // freopen("input.txt","r",stdin);

    cin>>n>>m;
    int i;
    int p;
    rep(i,2,n + 1)  {
        cin>>p;
        v[p].pb(i);
    }
    cin>>str;

    dfs(1,1);
    int ver,dist;
    while(m--){
        cin>>ver>>dist;
        int L = entry[ver];
        int H = out[ver];
        int odd= 0;
        int k;
        rep(k,0,26){

            int lo = lower_bound(A[dist][k].begin(),A[dist][k].end(),L) - A[dist][k].begin();
            int hi = upper_bound(A[dist][k].begin(),A[dist][k].end(),H) - A[dist][k].begin();
            // cout<<L<<"  "<<H<<"   "<<lo<<"  "<<hi<<endl;
            if((hi - lo) & 1)   odd++;

        }

        if(odd == 1 || odd == 0)    {
            cout<<"Yes\n";
        }
        else {
            cout<<"No\n";
        }

    }

return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int N = 500003;
vector <short> v[N][26], g[N];
short h[N], l[N], r[N], which[N], unit = -1;
char s[N];

void dfs(int node) {
	which[node] = ++unit;
	l[which[node]] = unit;
	for (int i = 0; i < g[node].size(); i++)
		dfs(g[node][i]);
	r[which[node]] = unit;
}

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	h[0] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x;
		scanf("%d", &x);
		g[--x].push_back(i + 1);
		h[i + 1] = h[x] + 1;
	}
	scanf("%s", s);
	dfs(0);
	for (int i = 0; i < n; i++)
		v[h[i]][s[i] - 'a'].push_back(which[i]);

	for (int i = 0; i < N; i++)
		for (int j = 0; j < 26; j++)
			sort(v[i][j].begin(), v[i][j].end());

	int node, dep, odds;
	while (m--) {
		scanf("%d %d", &node, &dep);
		node = which[--node];
		odds = 0;
		for (int i = 0; i < 26; i++) {
			if (!v[dep][i].size())
				continue;
			short low = lower_bound(v[dep][i].begin(), v[dep][i].end(), l[node]) - v[dep][i].begin();
			short high = lower_bound(v[dep][i].begin(), v[dep][i].end(), r[node]) - v[dep][i].begin();
			if (low >= v[dep][i].size())
				continue;
			if (high >= v[dep][i].size() || v[dep][i][high] > r[node])
				high--;
			if (high >= 0 && (high - low + 1) % 2) {
				odds++;
				if (odds == 2)
					break;
			}
		}
		if (odds <= 1)
			printf("Yes\n");
		else printf("No\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 500003;
vector <int> v[N], g[N], sum[N][26];
int h[N], l[N], r[N], which[N], unit = -1;
char s[N], to[N];

void dfs(int node) {
	which[node] = ++unit;
	l[which[node]] = unit;
	to[which[node]] = s[node] - 'a';
	for (int i = 0; i < g[node].size(); i++)
		dfs(g[node][i]);
	r[which[node]] = unit;
}

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	h[0] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x;
		scanf("%d", &x);
		g[--x].push_back(i + 1);
		h[i + 1] = h[x] + 1;
	}
	scanf("%s", s);
	dfs(0);
	for (int i = 0; i < n; i++)
		v[h[i]].push_back(which[i]);
	for (int i = 0; i < n + 1; i++)
		sort(v[i].begin(), v[i].end());
	for (int i = 0; i < n + 1; i++)
		for (int j = 0; j < 26; j++) {
			if (v[i].empty())
				continue;
			sum[i][j].push_back(to[v[i][0]] == j);
			for (int k = 1; k < v[i].size(); k++)
				sum[i][j].push_back(sum[i][j].back() + (to[v[i][k]] == j));
		}

	while (m--) {
		int node, dep, odds = 0;
		scanf("%d %d", &node, &dep);
		node = which[--node];
		int low = lower_bound(v[dep].begin(), v[dep].end(), l[node]) - v[dep].begin();
		int high = upper_bound(v[dep].begin(), v[dep].end(), r[node]) - v[dep].begin();
		high--;
		if (v[dep].size())
			for (int i = 0; i < 26; i++)
				odds += (sum[dep][i][high] - (low ? sum[dep][i][low - 1] : 0)) % 2;
		if (odds <= 1)
			printf("Yes\n");
		else printf("No\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 500003;
vector <int> v[N][26], g[N];
int h[N], l[N], r[N], which[N], unit = -1;
char s[N];

void dfs(int node) {
	unit++;
	which[node] = unit;
	l[node] = unit;
	for (int i = 0; i < g[node].size(); i++)
		dfs(g[node][i]);
	r[node] = unit;
}

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	h[0] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x;
		scanf("%d", &x);
		g[--x].push_back(i + 1);
		h[i + 1] = h[x] + 1;
	}
	scanf("%s", s);
	dfs(0);
	for (int i = 0; i < n; i++)
		v[h[i]][s[i] - 'a'].push_back(which[i]);

	for (int i = 0; i < N; i++)
		for (int j = 0; j < 26; j++)
			sort(v[i][j].begin(), v[i][j].end());

	while (m--) {
		int node, dep;
		scanf("%d %d", &node, &dep);
		node = which[--node];
		int odds = 0;
		for (int i = 0; i < 26; i++) {
			if (!v[dep][i].size())
				continue;
			int low = lower_bound(v[dep][i].begin(), v[dep][i].end(), l[node]) - v[dep][i].begin();
			int high = upper_bound(v[dep][i].begin(), v[dep][i].end(), r[node]) - v[dep][i].begin();
			if (low >= v[dep][i].size())
				continue;
			if (high >= v[dep][i].size() || v[dep][i][high] > r[node])
				high--;
			if (high >= 0 && (high - low + 1) % 2)
				odds++;
		}
		if (odds <= 1)
			printf("Yes\n");
		else printf("No\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 500003;
vector <int> v[N][26], g[N];
int h[N], l[N], r[N], which[N], unit = -1;
char s[N];

void dfs(int node) {
	which[node] = ++unit;
	l[which[node]] = unit;
	for (int i = 0; i < g[node].size(); i++)
		dfs(g[node][i]);
	r[which[node]] = unit;
}

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	h[0] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x;
		scanf("%d", &x);
		g[--x].push_back(i + 1);
		h[i + 1] = h[x] + 1;
	}
	scanf("%s", s);
	dfs(0);
	for (int i = 0; i < n; i++)
		v[h[i]][s[i] - 'a'].push_back(which[i]);

	for (int i = 0; i < N; i++)
		for (int j = 0; j < 26; j++)
			sort(v[i][j].begin(), v[i][j].end());

	while (m--) {
		int node, dep;
		scanf("%d %d", &node, &dep);
		node = which[--node];
		int odds = 0;
		for (int i = 0; i < 26; i++) {
			if (!v[dep][i].size())
				continue;
			int low = lower_bound(v[dep][i].begin(), v[dep][i].end(), l[node]) - v[dep][i].begin();
			int high = lower_bound(v[dep][i].begin(), v[dep][i].end(), r[node]) - v[dep][i].begin();
			if (low >= v[dep][i].size())
				continue;
			if (high >= v[dep][i].size() || v[dep][i][high] > r[node])
				high--;
			if (high >= 0 && (high - low + 1) % 2)
				odds++;
		}
		if (odds <= 1)
			printf("Yes\n");
		else printf("No\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 500003;
vector <int> v[N], g[N], sum[N];
int h[N], l[N], r[N], which[N], unit = -1;
char s[N], to[N];

void dfs(int node) {
	which[node] = ++unit;
	l[which[node]] = unit;
	to[which[node]] = s[node] - 'a';
	for (int i = 0; i < g[node].size(); i++)
		dfs(g[node][i]);
	r[which[node]] = unit;
}

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	h[0] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x;
		scanf("%d", &x);
		g[--x].push_back(i + 1);
		h[i + 1] = h[x] + 1;
	}
	scanf("%s", s);
	dfs(0);
	for (int i = 0; i < n; i++)
		v[h[i]].push_back(which[i]);
	for (int i = 0; i < n + 1; i++)
		sort(v[i].begin(), v[i].end());
	for (int i = 0; i < n + 1; i++) {
		if (v[i].empty())
			continue;
		sum[i].push_back(1 << to[v[i][0]]);
		for (int j = 1; j < v[i].size(); j++) {
			int temp = sum[i].back();
			temp ^= 1 << to[v[i][j]];
			sum[i].push_back(temp);
		}
	}

	while (m--) {
		int node, dep, odds = 0;
		scanf("%d %d", &node, &dep);
		node = which[--node];
		int low = lower_bound(v[dep].begin(), v[dep].end(), l[node]) - v[dep].begin();
		int high = lower_bound(v[dep].begin(), v[dep].end(), r[node]) - v[dep].begin();
		if (high == v[dep].size() || v[dep][high] > r[node])
			high--;
		if (v[dep].empty() || high < 0 || low == v[dep].size()) {
			printf("Yes\n");
			continue;
		}
		for (int i = 0; i < 26; i++)
			odds += ((sum[dep][high] >> i) ^ (low ? (sum[dep][low - 1] >> i) : 0)) & 1;
		if (odds <= 1)
			printf("Yes\n");
		else printf("No\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 500003;
vector <int> v[N], g[N], sum[N][26];
int h[N], l[N], r[N], which[N], unit = -1;
char s[N], to[N];

void dfs(int node) {
	which[node] = ++unit;
	l[which[node]] = unit;
	to[which[node]] = s[node] - 'a';
	for (int i = 0; i < g[node].size(); i++)
		dfs(g[node][i]);
	r[which[node]] = unit;
}

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	h[0] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x;
		scanf("%d", &x);
		g[--x].push_back(i + 1);
		h[i + 1] = h[x] + 1;
	}
	scanf("%s", s);
	dfs(0);
	for (int i = 0; i < n; i++)
		v[h[i]].push_back(which[i]);
	for (int i = 0; i < n + 1; i++)
		sort(v[i].begin(), v[i].end());
	for (int i = 0; i < n + 1; i++)
		for (int j = 0; j < 26; j++) {
			if (v[i].empty())
				continue;
			sum[i][j].push_back(to[v[i][0]] == j);
			for (int k = 1; k < v[i].size(); k++)
				sum[i][j].push_back(sum[i][j].back() + (to[v[i][k]] == j));
		}

	while (m--) {
		int node, dep, odds = 0;
		scanf("%d %d", &node, &dep);
		node = which[--node];
		int low = lower_bound(v[dep].begin(), v[dep].end(), l[node]) - v[dep].begin();
		int high = lower_bound(v[dep].begin(), v[dep].end(), r[node]) - v[dep].begin();
		if (high == v[dep].size() || v[dep][high] > r[node])
			high--;
		if (v[dep].empty() || high < 0 || low == v[dep].size()) {
			printf("Yes\n");
			continue;
		}
		for (int i = 0; i < 26; i++)
			odds += (sum[dep][i][high] - (low ? sum[dep][i][low - 1] : 0)) & 1;
		if (odds <= 1)
			printf("Yes\n");
		else printf("No\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 500003;
vector <int> v[N], g[N], sum[N][26];
int h[N], l[N], r[N], which[N], unit = -1;
char s[N], to[N];

void dfs(int node) {
	which[node] = ++unit;
	l[which[node]] = unit;
	to[which[node]] = s[node] - 'a';
	for (int i = 0; i < g[node].size(); i++)
		dfs(g[node][i]);
	r[which[node]] = unit;
}

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	h[0] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x;
		scanf("%d", &x);
		g[--x].push_back(i + 1);
		h[i + 1] = h[x] + 1;
	}
	scanf("%s", s);
	dfs(0);
	for (int i = 0; i < n; i++)
		v[h[i]].push_back(which[i]);
	for (int i = 0; i < n + 1; i++)
		sort(v[i].begin(), v[i].end());
	for (int i = 0; i < n + 1; i++)
		for (int j = 0; j < 26; j++) {
			if (v[i].empty())
				continue;
			sum[i][j].push_back(to[v[i][0]] == j);
			for (int k = 1; k < v[i].size(); k++)
				sum[i][j].push_back(sum[i][j].back() + (to[v[i][k]] == j));
		}

	while (m--) {
		int node, dep, odds = 0;
		scanf("%d %d", &node, &dep);
		node = which[--node];
		int low = lower_bound(v[dep].begin(), v[dep].end(), l[node]) - v[dep].begin();
		int high = lower_bound(v[dep].begin(), v[dep].end(), r[node]) - v[dep].begin();
		if (high == v[dep].size() || v[dep][high] > r[node])
			high--;
		if (low == v[dep].size()) {
			printf("No\n");
			continue;
		}
		if (v[dep].empty() || high < 0) {
			printf("Yes\n");
			continue;
		}
		for (int i = 0; i < 26; i++)
			odds += (sum[dep][i][high] - (low ? sum[dep][i][low - 1] : 0)) & 1;
		if (odds <= 1)
			printf("Yes\n");
		else printf("No\n");
	}
}


#include <bits/stdc++.h>

using namespace std;

const int N = 500003;
vector <int> v[N], g[N], sum[N][26];
int h[N], l[N], r[N], which[N], unit = -1;
char s[N], to[N];

void dfs(int node) {
	which[node] = ++unit;
	l[which[node]] = unit;
	to[which[node]] = s[node] - 'a';
	for (int i = 0; i < g[node].size(); i++)
		dfs(g[node][i]);
	r[which[node]] = unit;
}

main() {
	int n, m;
	scanf("%d %d", &n, &m);
	h[0] = 1;
	for (int i = 0; i < n - 1; i++) {
		int x;
		scanf("%d", &x);
		g[--x].push_back(i + 1);
		h[i + 1] = h[x] + 1;
	}
	scanf("%s", s);
	dfs(0);
	for (int i = 0; i < n; i++)
		v[h[i]].push_back(which[i]);
	for (int i = 0; i < N; i++)
		sort(v[i].begin(), v[i].end());
	for (int i = 0; i < N; i++)
		for (int j = 0; j < 26; j++) {
			if (v[i].empty())
				continue;
			sum[i][j].push_back(to[v[i][0]] == j);
			for (int k = 1; k < v[i].size(); k++)
				sum[i][j].push_back(sum[i][j].back() + (to[v[i][k]] == j));
		}

	while (m--) {
		int node, dep, odds = 0;
		scanf("%d %d", &node, &dep);
		node = which[--node];
		int low = lower_bound(v[dep].begin(), v[dep].end(), l[node]) - v[dep].begin();
		int high = upper_bound(v[dep].begin(), v[dep].end(), r[node]) - v[dep].begin();
		high--;
		for (int i = 0; i < 26; i++)
			odds += (sum[dep][i][high] - (low ? sum[dep][i][low - 1] : 0)) % 2;
		if (odds <= 1)
			printf("Yes\n");
		else printf("No\n");
	}
}


#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int c, n, m, v, h, p[500010], dep[500010], Hash[500010], mmax[500010], reHash[500010];
char str[500010];
vector< vector<int> > node;
vector<int> data[500010][26];

void dfs(int here){
    Hash[here]=++c;
    for(int i=0 ; i<node[here].size() ; ++i)
        dfs(node[here][i]);
}

int getMax(int here){
    int& ret=mmax[here];

    ret=here;
    for(int i=0 ; i<node[here].size() ; ++i)
        ret=max(ret, getMax(node[here][i]));
    return ret;
}

void inIt(int here, int cnt){
    char ch=str[reHash[here]-1];
    int idx=ch-'a';
    data[cnt][idx].push_back(here);
    for(int i=0 ; i<node[here].size() ; ++i)
        inIt(node[here][i], cnt+1);
}

int main(){
    scanf("%d%d", &n, &m);
    node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        scanf("%d", &p[i]);
        node[p[i]].push_back(i);
    }
    scanf("%s", str);

    dfs(1);
    for(int i=1 ; i<=n ; ++i){
        int hashValue=Hash[i];
        reHash[hashValue]=i;
    }

    node.clear(); node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        int here=Hash[i], parent=Hash[p[i]];
        node[parent].push_back(here);
    }
    getMax(1);

    inIt(1, 1);
    for(int i=1 ; i<=n ; ++i){
        for(int j=0 ; j<26 ; ++j)
            sort(data[i][j].begin(), data[i][j].end());
    }

    while(m--){
        scanf("%d%d", &v, &h);
        if(dep[v]>=h || node[v].empty()) puts("Yes");
        else{
            int lo=Hash[v], hi=mmax[lo], odd=0;
            for(int i=0 ; i<26 ; ++i){
                vector<int> vi=data[h][i];
                vector<int>::iterator llo=lower_bound(vi.begin(), vi.end(), lo);
                vector<int>::iterator hhi=upper_bound(vi.begin(), vi.end(), hi);
                int temp=hhi-llo;
                if(temp&1) ++odd;
            }
            if(odd>=2) puts("No");
            else puts("Yes");
        }
    }
}


#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int c, n, m, v, h, p, dep[500010], Hash[500010], mmax[500010];
char str[500010];
vector< vector<int> > node;
vector<int> data[500010][26];

int dfs(int here, int cnt){
    Hash[here]=++c;
    int idx=str[here-1]-'a';
    data[cnt][idx].push_back(Hash[here]);

    int& ret=mmax[Hash[here]];
    ret=Hash[here];

    for(int i=0 ; i<node[here].size() ; ++i)
        ret=max(ret, dfs(node[here][i], cnt+1));

    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        scanf("%d", &p);
        node[p].push_back(i);
    }
    scanf("%s", str);

    dfs(1, 1);
    while(m--){
        scanf("%d%d", &v, &h);
        int odd=0, lo=Hash[v], hi=mmax[Hash[v]];
        for(int i=0 ; i<26 ; ++i){
            vector<int>& vi=data[h][i];
            vector<int>::iterator llo=lower_bound(vi.begin(), vi.end(), lo);
            vector<int>::iterator hhi=upper_bound(vi.begin(), vi.end(), hi);
            int temp=hhi-llo;
            if(temp&1) ++odd;
        }
        if(odd>=2) puts("No");
        else puts("Yes");
    }
}


#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int c, n, m, v, h, p[500010], dep[500010], Hash[500010], mmax[500010], reHash[500010];
char str[500010];
vector< vector<int> > node;
vector<int> data[500010][26];

void dfs(int here){
    Hash[here]=++c;
    for(int i=0 ; i<node[here].size() ; ++i)
        dfs(node[here][i]);
}

int inIt(int here, int cnt){
    char ch=str[reHash[here]-1];
    int idx=ch-'a';
    data[cnt][idx].push_back(here);

    int& ret=mmax[here];
    ret=here;
    for(int i=0 ; i<node[here].size() ; ++i)
        ret=max(ret, inIt(node[here][i], cnt+1));
    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        scanf("%d", &p[i]);
        node[p[i]].push_back(i);
    }
    scanf("%s", str);

    dfs(1);
    for(int i=1 ; i<=n ; ++i){
        int hashValue=Hash[i];
        reHash[hashValue]=i;
    }

    node.clear(); node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        int here=Hash[i], parent=Hash[p[i]];
        node[parent].push_back(here);
    }

    inIt(1, 1);
    while(m--){
        scanf("%d%d", &v, &h);
        if(dep[v]>=h || node[v].empty()) puts("Yes");
        else{
            int lo=Hash[v], hi=mmax[lo], odd=0;
            for(int i=0 ; i<26 ; ++i){
                vector<int>& vi=data[h][i];
                vector<int>::iterator llo=lower_bound(vi.begin(), vi.end(), lo);
                vector<int>::iterator hhi=upper_bound(vi.begin(), vi.end(), hi);
                int temp=hhi-llo;
                if(temp&1) ++odd;
            }
            if(odd>=2) puts("No");
            else puts("Yes");
        }
    }
}


#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int c, n, m, v, h, p[500010], dep[500010], Hash[500010], mmax[500010], reHash[500010];
char str[500010];
vector< vector<int> > node;
vector<int> data[500010][26];

void dfs(int here){
    Hash[here]=++c;
    for(int i=0 ; i<node[here].size() ; ++i)
        dfs(node[here][i]);
}

int inIt(int here, int cnt){
    char ch=str[reHash[here]-1];
    int idx=ch-'a';
    data[cnt][idx].push_back(here);

    int& ret=mmax[here];
    ret=here;
    for(int i=0 ; i<node[here].size() ; ++i)
        ret=max(ret, inIt(node[here][i], cnt+1));
    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        scanf("%d", &p[i]);
        node[p[i]].push_back(i);
    }
    scanf("%s", str);

    dfs(1);
    for(int i=1 ; i<=n ; ++i){
        int hashValue=Hash[i];
        reHash[hashValue]=i;
    }

    node.clear(); node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        int here=Hash[i], parent=Hash[p[i]];
        node[parent].push_back(here);
    }

    inIt(1, 1);
    while(m--){
        scanf("%d%d", &v, &h);
        if(dep[Hash[v]]>=h || node[Hash[v]].empty()) puts("Yes");
        else{
            int lo=Hash[v], hi=mmax[lo], odd=0;
            for(int i=0 ; i<26 ; ++i){
                vector<int>& vi=data[h][i];
                vector<int>::iterator llo=lower_bound(vi.begin(), vi.end(), lo);
                vector<int>::iterator hhi=upper_bound(vi.begin(), vi.end(), hi);
                int temp=hhi-llo;
                if(temp&1) ++odd;
            }
            if(odd>=2) puts("No");
            else puts("Yes");
        }
    }
}


#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int c, n, m, v, h, p[500010], dep[500010], Hash[500010], mmax[500010], reHash[500010];
char str[500010];
vector< vector<int> > node;
vector<int> data[500010][26];

int dfs(int here, int cnt){
    Hash[here]=++c;
    int idx=str[here-1]-'a';
    data[cnt][idx].push_back(Hash[here]);

    int& ret=mmax[Hash[here]];
    ret=Hash[here];

    for(int i=0 ; i<node[here].size() ; ++i)
        ret=max(ret, dfs(node[here][i], cnt+1));

    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        scanf("%d", &p[i]);
        node[p[i]].push_back(i);
    }
    scanf("%s", str);

    dfs(1, 1);
    while(m--){
        scanf("%d%d", &v, &h);
        int odd=0, lo=Hash[v], hi=mmax[Hash[v]];
        for(int i=0 ; i<26 ; ++i){
            vector<int>& vi=data[h][i];
            vector<int>::iterator llo=lower_bound(vi.begin(), vi.end(), lo);
            vector<int>::iterator hhi=upper_bound(vi.begin(), vi.end(), hi);
            int temp=hhi-llo;
            if(temp&1) ++odd;
        }
        if(odd>=2) puts("No");
        else puts("Yes");
    }
}


#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int c, n, m, v, h, p, dep[500010], Hash[500010], mmax[500010];
char str[500010];
vector< vector<int> > node;
vector<int> data[500010][26];

int dfs(int here, int cnt){
    Hash[here]=++c;
    int idx=str[here-1]-'a';
    data[cnt][idx].push_back(Hash[here]);

    int& ret=mmax[Hash[here]];
    ret=Hash[here];

    for(int i=0 ; i<node[here].size() ; ++i)
        ret=max(ret, dfs(node[here][i], cnt+1));

    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        scanf("%d", &p);
        node[p].push_back(i);
    }
    scanf("%s", str);

    dfs(1, 1);
    while(m--){
        scanf("%d%d", &v, &h);
        int odd=0, lo=Hash[v], hi=mmax[Hash[v]];

        if(dep[lo]>=h || node[v].empty()) puts("Yes");
        else{
            for(int i=0 ; i<26 ; ++i){
                vector<int>& vi=data[h][i];
                vector<int>::iterator llo=lower_bound(vi.begin(), vi.end(), lo);
                vector<int>::iterator hhi=upper_bound(vi.begin(), vi.end(), hi);
                int temp=hhi-llo;
                if(temp&1) ++odd;
            }
            if(odd>=2) puts("No");
            else puts("Yes");
        }
    }
}


#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int c, n, m, v, h, p[500010], dep[500010], Hash[500010], mmax[500010], reHash[500010];
char str[500010];
vector< vector<int> > node;
vector<int> data[500010][26];

void dfs(int here){
    Hash[here]=++c;
    for(int i=0 ; i<node[here].size() ; ++i)
        dfs(node[here][i]);
}

int getMax(int here){
    int& ret=mmax[here];

    ret=here;
    for(int i=0 ; i<node[here].size() ; ++i)
        ret=max(ret, getMax(node[here][i]));
    return ret;
}

void inIt(int here, int cnt){
    char ch=str[reHash[here]-1];
    int idx=ch-'a';
    data[cnt][idx].push_back(here);
    for(int i=0 ; i<node[here].size() ; ++i)
        inIt(node[here][i], cnt+1);
}

int main(){    scanf("%d%d", &n, &m);
    node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        scanf("%d", &p[i]);
        node[p[i]].push_back(i);
    }
    scanf("%s", str);

    dfs(1);
    for(int i=1 ; i<=n ; ++i){
        int hashValue=Hash[i];
        reHash[hashValue]=i;
    }

    node.clear(); node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        int here=Hash[i], parent=Hash[p[i]];
        node[parent].push_back(here);
    }
    getMax(1);

    inIt(1, 1);
    while(m--){
        scanf("%d%d", &v, &h);
        if(dep[v]>=h || node[v].empty()) puts("Yes");
        else{
            int lo=Hash[v], hi=mmax[lo], odd=0;
            for(int i=0 ; i<26 ; ++i){
                vector<int> vi=data[h][i];
                vector<int>::iterator llo=lower_bound(vi.begin(), vi.end(), lo);
                vector<int>::iterator hhi=upper_bound(vi.begin(), vi.end(), hi);
                int temp=hhi-llo;
                if(temp&1) ++odd;
            }
            if(odd>=2) puts("No");
            else puts("Yes");
        }
    }
}


#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int c, n, m, v, h, p[500010], dep[500010], Hash[500010], mmax[500010], reHash[500010];
char str[500010];
vector< vector<int> > node;
vector<int> data[500010][26];

void dfs(int here){
    Hash[here]=++c;
    for(int i=0 ; i<node[here].size() ; ++i)
        dfs(node[here][i]);
}

int inIt(int here, int cnt){
    char ch=str[reHash[here]-1];
    int idx=ch-'a';
    data[cnt][idx].push_back(here);

    int& ret=mmax[here];
    ret=here;
    for(int i=0 ; i<node[here].size() ; ++i)
        ret=max(ret, inIt(node[here][i], cnt+1));
    return ret;
}

int main(){
    scanf("%d%d", &n, &m);
    node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        scanf("%d", &p[i]);
        node[p[i]].push_back(i);
    }
    scanf("%s", str);

    dfs(1);
    for(int i=1 ; i<=n ; ++i){
        int hashValue=Hash[i];
        reHash[hashValue]=i;
    }

    node.clear(); node.resize(n+1);
    for(int i=2 ; i<=n ; ++i){
        int here=Hash[i], parent=Hash[p[i]];
        node[parent].push_back(here);
    }

    inIt(1, 1);
    while(m--){
        scanf("%d%d", &v, &h);
        if(dep[v]>=h || node[v].empty()) puts("Yes");
        else{
            int lo=Hash[v], hi=mmax[lo], odd=0;
            for(int i=0 ; i<26 ; ++i){
                vector<int> vi=data[h][i];
                vector<int>::iterator llo=lower_bound(vi.begin(), vi.end(), lo);
                vector<int>::iterator hhi=upper_bound(vi.begin(), vi.end(), hi);
                int temp=hhi-llo;
                if(temp&1) ++odd;
            }
            if(odd>=2) puts("No");
            else puts("Yes");
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;

struct node
{
    int to, next;
}edge[maxn];
int head[maxn], l[maxn], r[maxn], cnt[maxn];
int  tot, dfn, deep[maxn];
char str[maxn];
vector < vector<int> > sum;
vector < vector<int> > p;

void init (int n)
{
    tot = dfn = 0;
    sum.clear();
    sum.resize(n+1);
    p.clear();
    p.resize(n+1);
    memset (head, -1, sizeof(head));
}
void Add (int from, int to)
{
    edge[tot].to = to;
    edge[tot].next = head[from];
    head[from] = tot++;
}
void dfs (int u)
{
    l[u] = ++dfn;
    cnt[l[u]] = u;
    p[deep[u]].push_back(l[u]);
    for (int i=head[u]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].to;
        deep[v] = deep[u] + 1;
        dfs (v);
    }
    r[u] = dfn;
}

int main ()
{
    int n, m;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init (n);
        for (int i=2; i<=n; i++)
        {
            int v;
            scanf ("%d", &v);
            Add (v, i);
        }
        deep[1] = 1;
        dfs (1);
        scanf ("%s", str+1);
        for (int i=1; i<=n; i++)
        {
            int size = p[i].size();
            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[cnt[p[i][j]]] -'a';
                sum[i][j] = 1<<x;
            }
            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }
        while (m --)
        {
            int x, h, L, R, size;
            scanf ("%d %d", &x, &h);
            size = p[h].size();
            L = p[h][0], R= p[h][size-1];
            if (h <= deep[x] || !size || l[x]>R || r[x]<L)
            {
                printf ("Yes\n");
                continue;
            }
            int left  = lower_bound(p[h].begin(), p[h].end(), l[x]) - p[h].begin();
            int right = lower_bound(p[h].begin(), p[h].end(), r[x]) - p[h].begin();
            if (right==size || p[h][right]>r[x])
                right --;
            int res = sum[h][right];
            if (left > 0)
                res ^= sum[h][left-1];
            int ans = 0;
            for (int i=0; i<26; i++)
            {
                if (res % 2)
                    ans ++;
                res /= 2;
                if (!res || ans>1)
                    break;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;

int l[maxn], r[maxn], cnt[maxn];
int dfn, deep[maxn];
char str[maxn];
vector < int > sum[maxn];
vector < int > p[maxn];
vector < int > maps[maxn];

void init (int n)
{
    dfn = 0;
    for (int i=0; i<maxn; i++)
    {
        maps[i].clear();
        sum[i].clear();
        p[i].clear();
    }
}

void dfs (int u)
{
    l[u] = ++dfn;
    cnt[l[u]] = u;
    p[deep[u]].push_back(l[u]);
    for (int i=0; i<maps[u].size(); i++)
    {
        int v = maps[u][i];
        deep[v] = deep[u] + 1;
        dfs (v);
    }
    r[u] = dfn;
}

int main ()
{
    int n, m;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init (n);
        for (int i=2; i<=n; i++)
        {
            int v;
            scanf ("%d", &v);
            maps[v].push_back(i);
        }
        deep[1] = 1;
        dfs (1);
        scanf ("%s", str+1);
        for (int i=1; i<=n; i++)
        {
            int size = p[i].size();
            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[cnt[p[i][j]]] -'a';
                sum[i][j] = 1<<x;
            }
            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }
        while (m --)
        {
            int x, h, L, R, size;
            scanf ("%d %d", &x, &h);
            size = p[h].size();
            L = p[h][0], R= p[h][size-1];
            if (h <= deep[x] || !size || l[x]>R || r[x]<L)
            {
                printf ("Yes\n");
                continue;
            }
            int left  = lower_bound(p[h].begin(), p[h].end(), l[x]) - p[h].begin();
            int right = lower_bound(p[h].begin(), p[h].end(), r[x]) - p[h].begin();
            if (right==size || p[h][right]>r[x])
                right --;
            int res = sum[h][right];
            if (left > 0)
                res ^= sum[h][left-1];
            int ans = 0;
            for (int i=0; i<26; i++)
            {
                if (res % 2)
                    ans ++;
                res /= 2;
                if (!res || ans>1)
                    break;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;

int l[maxn], r[maxn], cnt[maxn];
int dfn, deep[maxn];
char str[maxn];
vector < int > sum[maxn];
vector < int > p[maxn];
vector < int > maps[maxn];

void init (int n)
{
    dfn = 0;
    for (int i=0; i<maxn; i++)
    {
        maps[i].clear();
        sum[i].clear();
        p[i].clear();
    }
}

void dfs (int u)
{
    l[u] = ++dfn;
    cnt[l[u]] = u;
    p[deep[u]].push_back(l[u]);
    for (int i=0; i<maps[u].size(); i++)
    {
        int v = maps[u][i];
        deep[v] = deep[u] + 1;
        dfs (v);
    }
    r[u] = dfn;
}

int main ()
{
    int n, m;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init (n);
        for (int i=2; i<=n; i++)
        {
            int v;
            scanf ("%d", &v);
            maps[v].push_back(i);
        }
        deep[1] = 1;
        dfs (1);
        scanf ("%s", str);
        for (int i=1; i<=n; i++)
        {
            int size = p[i].size();
            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[cnt[p[i][j]]-1] -'a';
                sum[i][j] = 1<<x;
            }
            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }
        while (m --)
        {
            int x, h, L, R, size;
            scanf ("%d %d", &x, &h);
            size = p[h].size();
            L = p[h][0], R= p[h][size-1];
            if (h <= deep[x] || !size || l[x]>R || r[x]<L)
            {
                printf ("Yes\n");
                continue;
            }
            int left  = lower_bound(p[h].begin(), p[h].end(), l[x]) - p[h].begin();
            int right = lower_bound(p[h].begin(), p[h].end(), r[x]) - p[h].begin();
            if (right==size || p[h][right]>r[x])
                right --;
            int res = sum[h][right];
            if (left > 0)
                res ^= sum[h][left-1];
            int ans = 0;
            for (int i=0; i<26; i++)
            {
                if (res % 2)
                    ans ++;
                res /= 2;
                if (!res || ans>1)
                    break;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;

int L[maxn], R[maxn], rp[maxn];
int dfn, dep[maxn];
char str[maxn];
vector < int > sum[maxn];
vector < int > node[maxn];
vector < int > tree[maxn];

void dfs (int u)
{
    L[u] = ++dfn;
    rp[L[u]] = u;
    node[dep[u]].push_back(L[u]);
    for (int i=0; i<tree[u].size(); i++)
    {
        int v = tree[u][i];
        dep[v] = dep[u] + 1;
        dfs (v);
    }
    R[u] = dfn;
}
void init (int n)
{
    dfn = 0;
    dep[1] = 1;
    for (int i=1; i<maxn; i++)
    {
        sum[i].clear();
        node[i].clear();
        tree[i].clear();
    }
}
int main ()
{
    int n, m;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init (n);
        for (int i=2; i<=n; i++)
        {
            int v;
            scanf ("%d", &v);
            tree[v].push_back(i);
        }
        dfs (1);
        scanf ("%s", str+1);
        for (int i=1; i<=n; i++)
        {
            int size = node[i].size();
            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[rp[node[i][j]]] - 'a';
                sum[i][j] |= (1<<x);
            }
            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }
        int x, h;
        while (m --)
        {
            scanf ("%d %d", &x, &h);
            int l, r, size;
            l = L[x];
            r = R[x];
            size = node[h].size();
            if (dep[x]>=h || !size || r<node[h][0] || l>node[h][size-1])
            {
                printf ("Yes\n");
                continue;
            }
            int a = lower_bound(node[h].begin(), node[h].end(), l) - node[h].begin();
            int b = lower_bound(node[h].begin(), node[h].end(), r) - node[h].begin();
            if (b == size || node[h][b]>r)
                b --;
            int res = sum[h][b];
            if (a)
                res ^= sum[h][a-1];
            int ans = 0;
            for (int i=0; i<26; i++)
            {
                if (res & (1<<i))
                    ans ++;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;

struct node
{
    int to, next;
}edge[maxn];
int head[maxn], l[maxn], r[maxn], cnt[maxn];
int  tot, dfn, deep[maxn];
char str[maxn];
vector < vector<int> > sum;
vector < vector<int> > p;

void init (int n)
{
    tot = dfn = 0;
    sum.clear();
    sum.resize(maxn);
    p.clear();
    p.resize(maxn);
    memset (head, -1, sizeof(head));
}
void Add (int from, int to)
{
    edge[tot].to = to;
    edge[tot].next = head[from];
    head[from] = tot++;
}
void dfs (int u)
{
    l[u] = ++dfn;
    cnt[l[u]] = u;
    p[deep[u]].push_back(l[u]);
    for (int i=head[u]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].to;
        deep[v] = deep[u] + 1;
        dfs (v);
    }
    r[u] = dfn;
}

int main ()
{
    int n, m;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init (n);
        for (int i=2; i<=n; i++)
        {
            int v;
            scanf ("%d", &v);
            Add (v, i);
        }
        deep[1] = 1;
        dfs (1);
        scanf ("%s", str+1);
        for (int i=1; i<=n; i++)
        {
            int size = p[i].size();
            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[cnt[p[i][j]]] -'a';
                sum[i][j] = 1<<x;
            }
            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }
        while (m --)
        {
            int x, h, L, R, size;
            scanf ("%d %d", &x, &h);
            size = p[h].size();
            L = p[h][0], R= p[h][size-1];
            if (h <= deep[x] || !size || l[x]>R || r[x]<L)
            {
                printf ("Yes\n");
                continue;
            }
            int left  = lower_bound(p[h].begin(), p[h].end(), l[x]) - p[h].begin();
            int right = lower_bound(p[h].begin(), p[h].end(), r[x]) - p[h].begin();
            if (right==size || p[h][right]>r[x])
                right --;
            int res = sum[h][right];
            if (left > 0)
                res ^= sum[h][left-1];
            int ans = 0;
            for (int i=0; i<26; i++)
            {
                if (res % 2)
                    ans ++;
                res /= 2;
                if (!res || ans>1)
                    break;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;

int l[maxn], r[maxn], cnt[maxn];
int dfn, deep[maxn];
char str[maxn];
vector < int > sum[maxn];
vector < int > p[maxn];
vector < int > maps[maxn];

void init (int n)
{
    dfn = 0;
    for (int i=0; i<maxn; i++)
    {
        maps[i].clear();
        sum[i].clear();
        p[i].clear();
    }
}

void dfs (int u)
{
    l[u] = ++dfn;
    cnt[l[u]] = u;
    p[deep[u]].push_back(l[u]);
    for (int i=0; i<maps[u].size(); i++)
    {
        int v = maps[u][i];
        deep[v] = deep[u] + 1;
        dfs (v);
    }
    r[u] = dfn;
}

int main ()
{
    int n, m;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init (n);
        for (int i=2; i<=n; i++)
        {
            int v;
            scanf ("%d", &v);
            maps[v].push_back(i);
        }
        deep[1] = 1;
        dfs (1);
        scanf ("%s", str+1);
        for (int i=1; i<=n; i++)
        {
            int size = p[i].size();
            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[cnt[p[i][j]]] -'a';
                sum[i][j] |= 1<<x;
            }
            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }
        while (m --)
        {
            int x, h, L, R, size;
            scanf ("%d %d", &x, &h);
            size = p[h].size();
            L = p[h][0], R= p[h][size-1];
            if (h <= deep[x] || !size || l[x]>R || r[x]<L)
            {
                printf ("Yes\n");
                continue;
            }
            int left  = lower_bound(p[h].begin(), p[h].end(), l[x]) - p[h].begin();
            int right = lower_bound(p[h].begin(), p[h].end(), r[x]) - p[h].begin();
            if (right==size || p[h][right]>r[x])
                right --;
            int res = sum[h][right];
            if (left > 0)
                res ^= sum[h][left-1];
            int ans = 0;
            for (int i=0; i<26; i++)
            {
                if (res % 2)
                    ans ++;
                res /= 2;
                if (!res || ans>1)
                    break;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;

int l[maxn], r[maxn], cnt[maxn];
int dfn, deep[maxn];
char str[maxn];
vector < int > sum[maxn];
vector < int > p[maxn];
vector < int > maps[maxn];

void init (int n)
{
    dfn = 0;
    for (int i=0; i<maxn; i++)
    {
        maps[i].clear();
        sum[i].clear();
        p[i].clear();
    }
}

void dfs (int u)
{
    l[u] = ++dfn;
    cnt[l[u]] = u;
    p[deep[u]].push_back(l[u]);
    for (int i=0; i<maps[u].size(); i++)
    {
        int v = maps[u][i];
        deep[v] = deep[u] + 1;
        dfs (v);
    }
    r[u] = dfn;
}

int main ()
{
    int n, m;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init (n);
        for (int i=2; i<=n; i++)
        {
            int v;
            scanf ("%d", &v);
            maps[v].push_back(i);
        }
        deep[1] = 1;
        dfs (1);
        scanf ("%s", str+1);
        for (int i=1; i<=n; i++)
        {
            int size = p[i].size();
            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[cnt[p[i][j]]] -'a';
                sum[i][j] = 1<<x;
            }
            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }
        while (m --)
        {
            int x, h, L, R, size;
            scanf ("%d %d", &x, &h);
            if (h <= deep[x])
            {
                printf ("Yes\n");
                continue;
            }
            size = p[h].size();
            L = p[h][0], R= p[h][size-1];
            if (!size || l[x]>R || r[x]<L)
            {
                printf ("Yes\n");
                continue;
            }
            int left  = lower_bound(p[h].begin(), p[h].end(), l[x]) - p[h].begin();
            int right = lower_bound(p[h].begin(), p[h].end(), r[x]) - p[h].begin();
            if (right==size || p[h][right]>r[x])
                right --;
            int res = sum[h][right];
            if (left > 0)
                res ^= sum[h][left-1];
            int ans = 0;
            for (int i=0; i<26; i++)
            {
                if (res % 2)
                    ans ++;
                res /= 2;
                if (!res || ans>1)
                    break;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;

struct node
{
    int to, next;
}edge[maxn];
int head[maxn], l[maxn], r[maxn], cnt[maxn];
int  tot, dfn, deep[maxn];
char str[maxn];
vector < vector<int> > sum;
vector < vector<int> > p;

void init (int n)
{
    tot = dfn = 0;
    sum.clear();
    sum.resize(n+1);
    p.clear();
    p.resize(n+1);
    memset (head, -1, sizeof(head));
}
void Add (int from, int to)
{
    edge[tot].to = to;
    edge[tot].next = head[from];
    head[from] = tot++;
}
void dfs (int u)
{
    l[u] = ++dfn;
    cnt[l[u]] = u;
    p[deep[u]].push_back(l[u]);
    for (int i=head[u]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].to;
        deep[v] = deep[u] + 1;
        dfs (v);
    }
    r[u] = dfn;
}

int main ()
{
    int n, m;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init (n);
        for (int i=2; i<=n; i++)
        {
            int v;
            scanf ("%d", &v);
            Add (v, i);
        }
        deep[1] = 1;
        dfs (1);
        scanf ("%s", str+1);
        for (int i=1; i<=n; i++)
        {
            int size = p[i].size();
            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[cnt[p[i][j]]] -'a';
                sum[i][j] = 1<<x;
            }
            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }
        while (m --)
        {
            int x, h, L, R, size;
            scanf ("%d %d", &x, &h);
            size = p[h].size();
            L = p[h][0], R= p[h][size-1];
            if (h <= deep[x] || !size || l[x]>R || r[x]<L)
            {
                printf ("Yes\n");
                continue;
            }
            int left  = lower_bound(p[h].begin(), p[h].end(), l[x]) - p[h].begin();
            int right = lower_bound(p[h].begin(), p[h].end(), r[x]) - p[h].begin();
            if (right==size || p[h][right]>r[x])
                right --;
            int res = sum[h][right];
            if (left > 0)
                res ^= sum[h][left-1];
            int ans = 0;
            for (int i=0; i<26; i++)
            {
                if (res % 2)
                    ans ++;
                res /= 2;
                if (!res || ans>1)
                    break;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 500005;
int L[maxn], R[maxn], deep[maxn];
int dfn, rp[maxn];
vector <int> tree[maxn];
vector <int> node[maxn];
vector <int> sum[maxn];
char str[maxn];

void init ()
{
    deep[1] = 1;
    dfn = 0;
    for (int i=0; i<maxn; i++)
    {
        tree[i].clear();
        node[i].clear();
        sum[i].clear();
    }
}
void dfs (int u)
{
    L[u] = ++ dfn;
    rp[L[u]] = u;
    node[deep[u]].push_back(L[u]);
    for (int i=0; i<tree[u].size(); i++)
    {
        int v = tree[u][i];
        deep[v] = deep[u] + 1;
        dfs (v);
    }
    R[u] = dfn;
}
int main ()
{
    int n, m, v;
    while (scanf ("%d %d", &n, &m) != EOF)
    {
        init ();
        for (int i=2; i<=n; i++)
        {
            scanf ("%d", &v);
            tree[v].push_back(i);
        }

        dfs (1);
        scanf ("%s", str+1);

        for (int i=1; i<=n; i++)
        {
            int size = node[i].size();

            for (int j=0; j<size; j++)
            {
                sum[i].push_back(0);
                int x = str[rp[node[i][j]]] - 'a';
                sum[i][j] = 1<<x;
            }

            for (int j=1; j<size; j++)
                sum[i][j] ^= sum[i][j-1];
        }

        while (m --)
        {
            int v, h, l, r, size;
            scanf ("%d %d", &v, &h);
            size = node[h].size();
            l = L[v];
            r = R[v];
            if (h<=deep[v] || !size || l>node[h][size-1] || r<node[h][0])
            {
                printf ("Yes\n");
                continue;
            }
            int x = lower_bound (node[h].begin(), node[h].end(), l) - node[h].begin();
            int y = lower_bound (node[h].begin(), node[h].end(), r) - node[h].begin();
            if (y == size || r<node[h][y])
                y --;
            int res = sum[h][y];
            if (x)
                res ^= sum[h][x-1];
            int ans = 0;
            while (res)
            {
                if (res%2)
                    ans ++;
                res /= 2;
            }
            printf ("%s\n", ans>1?"No":"Yes");
        }
    }
    return 0;
}


#include <cassert>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

#define err(...) fprintf(stderr,__VA_ARGS__)

int N,Q;
int par[500001];
char label[500001];
int depth[500001];
std::vector<unsigned> level[500001];
std::vector<unsigned> cumxor[500001];

std::vector<unsigned> children[500001];
int perm[500001];
int finaldesc[500001];

void traverse(int n, int &i) {
	perm[n] = i++;
	level[depth[n]].push_back(n);
	int offset = (int) (label[n]-'a');
	cumxor[depth[n]].push_back(1<<offset);
	int k = cumxor[depth[n]].size()-1;
	if (k>0) cumxor[depth[n]][k] = cumxor[depth[n]][k] ^ cumxor[depth[n]][k-1];
	for (int j=0; j<children[n].size(); j++) traverse(children[n][j],i);
	finaldesc[n] = i-1;
}

int main() {
	std::cin >> N >> Q;
	for (int n=1; n<=N; n++) {
		level[n].clear();
		cumxor[n].clear();
		children[n].clear();
	}
	par[1] = 0;
	depth[1] = 1;
	level[1].push_back(1);
	for (int n=2; n<=N; n++) {
		scanf("%d",par+n);
		children[par[n]].push_back(n);
		depth[n] = depth[par[n]]+1;
	}
	std::string s; std::cin >> s;
	for (int n=1; n<=N; n++) {
		label[n] = s[n-1];
	}

	int i=1;
	traverse(1,i);

	for (int q=1; q<=Q; q++) {
		int n,lev; scanf("%d %d",&n,&lev);
		if (level[lev].size() == 0 || perm[level[lev][0]] > finaldesc[n] || perm[level[lev][level[lev].size()-1]] < perm[n]) {
			printf("Yes\n");
			continue;
		}
		int l=0; int r=level[lev].size();
		while (l+1<r) {
			int m = (l+r)/2;
			if (perm[level[lev][m]] <= finaldesc[n]) l=m;
			else r=m;
		}
		int R = l;
		int ll=-1; int rr=level[lev].size()-1;
		while (ll+1<rr) {
			int mm = (ll+rr)/2;
			if (perm[level[lev][mm]] >= perm[n]) rr=mm;
			else ll=mm;
		}
		int L = rr;

		int overcount = cumxor[lev][R];
		int correction;
		if (L==0) correction = 0;
		else correction = cumxor[lev][L-1];
		int tot = (overcount ^ correction);

		int bits = 0;
		for (int b=0; b<26; b++) {
			if (tot&(1LL<<b)) bits++;
		}
		if (bits >= 2) printf("No\n");
		else printf("Yes\n");
	}
}


#include <cassert>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
#define err(...) fprintf(stderr,__VA_ARGS__)

int N,Q; //Nodes; queries
int par[500001];
char label[500001];
int depth[500001];
vector<int> level[500001];
vector<int> cumxor[500001];

vector<int> children[500001];
int perm[500001];
int finaldesc[500001];

void traverse(int n, int &i) {
	perm[n] = i++;
	level[depth[n]].push_back(n);
	cumxor[depth[n]].push_back(1<<(label[n]-'a'));
	int k = cumxor[depth[n]].size()-1;
	if (k>0) cumxor[depth[n]][k] ^= cumxor[depth[n]][k-1];
	for (int j=0; j<children[n].size(); j++) traverse(children[n][j],i);
	finaldesc[n] = i-1;
}

int main() {
	cin >> N >> Q;
	par[1] = 0;
	depth[1] = 1;
	level[1].push_back(1);
	for (int n=2; n<=N; n++) {
		scanf("%d",par+n);
		children[par[n]].push_back(n);
		depth[n] = depth[par[n]]+1;
	}
	string s; cin >> s;
	for (int n=1; n<=N; n++) {
		label[n] = s[n-1];
	}

	int i=1;
	traverse(1,i);

	//for (int n=1; n<=N; n++) err("perm[%d]=%d... encompases perm[%d] through perm[%d].\n",n,perm[n],perm[n],finaldesc[n]);

	set<int> ok;
	ok.insert(0);
	for (int i=0; i<26; i++) ok.insert(1<<i);
	for (int q=1; q<=Q; q++) {
		int n,lev; scanf("%d %d",&n,&lev);
		if (level[lev].size() == 0 || perm[level[lev][0]] > finaldesc[n] || perm[level[lev][level[lev].size()-1]] < perm[n]) {
			printf("Yes\n");
			continue;
		}

		//Find largest R such that perm[level[lev][R]] <=  finaldesc[n];
		//Where I interpret perm[level[lev][-1] as -infty and perm[level[lev][size]] as infty
		int l=0; int r=level[lev].size();
		while (l+1<r) {
			int m = (l+r)/2;
			if (perm[level[lev][m]] <= finaldesc[n]) l=m;
			else r=m;
		}
		int R = l;
		assert(perm[level[lev][R]] <= finaldesc[n] &&
			(R == level[lev].size()-1 || perm[level[lev][R+1]] > finaldesc[n]));
		//Find smallest L such that perm[level[l][L]] >= perm[n]
		l=-1; r=level[lev].size()-1;
		while (l+1<r) {
			int m = (l+r)/2;
			if (perm[level[lev][m]] >= perm[n]) r=m;
			else l=m;
		}
		int L = r;
		assert(perm[level[lev][L]] >= perm[n] &&
			(L==0 || perm[level[lev][L-1]] < perm[n]));

		//err("nodes at depth %d: ",lev);
		//for (int i=0; i<level[lev].size(); i++) err("%d ",level[lev][i]);
		//err("Those underneath %d: from %d to %d.\n",n,level[lev][L],level[lev][R]);
		//err("cumxors: "); for (int i=0; i<level[lev].size(); i++) err("%d ",cumxor[lev][i]);

		int overcount = cumxor[lev][R];
		int correction = (L == 0)? 0 : cumxor[lev][L-1];
		int sum = overcount ^ correction;

		//sum = 0;
		//for (int i=L; i<=R; i++) sum ^= (1<<(s[level[lev][i]-1]-'a'));
		//err("Sum: %d ",sum);
		//err("This shoudl be the xor of: [%d:%d]",L,R);
		//for (int i=L; i<=R; i++) {
		//	err(" %c",label[level[lev][i]]);
		//} err("\n");

		if (ok.count(sum) == 0) printf("No\n");
		else printf("Yes\n");
	}
}


#include <cassert>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

typedef long long ll;
#define err(...) fprintf(stderr,__VA_ARGS__)

int N,Q;
int par[500001];
char label[500001];
int depth[500001];
std::vector<unsigned> level[500001];
std::vector<unsigned> cumxor[500001];

std::vector<unsigned> children[500001];
int perm[500001];
int finaldesc[500001];

void traverse(int n, int &i) {
	perm[n] = i++;
	level[depth[n]].push_back(n);
	int offset = (int) (label[n]-'a');
	cumxor[depth[n]].push_back(1<<offset);
	int k = cumxor[depth[n]].size()-1;
	if (k>0) cumxor[depth[n]][k] = cumxor[depth[n]][k] ^ cumxor[depth[n]][k-1];
	for (int j=0; j<children[n].size(); j++) traverse(children[n][j],i);
	finaldesc[n] = i-1;
}

int main() {
	std::cin >> N >> Q;
	for (int n=1; n<=N; n++) {
		level[n].clear();
		cumxor[n].clear();
		children[n].clear();
	}
	par[1] = 0;
	depth[1] = 1;
	level[1].push_back(1);
	for (int n=2; n<=N; n++) {
		scanf("%d",par+n);
		children[par[n]].push_back(n);
		depth[n] = depth[par[n]]+1;
	}
	std::string s; std::cin >> s;
	for (int n=1; n<=N; n++) {
		label[n] = s[n-1];
	}

	int i=1;
	traverse(1,i);

	for (int q=1; q<=Q; q++) {
		int n,lev; scanf("%d %d",&n,&lev);
		if (level[lev].size() == 0 || perm[level[lev][0]] > finaldesc[n] || perm[level[lev][level[lev].size()-1]] < perm[n]) {
			printf("Yes\n");
			continue;
		}
		int l=0; int r=level[lev].size();
		while (l+1<r) {
			int m = (l+r)/2;
			if (perm[level[lev][m]] <= finaldesc[n]) l=m;
			else r=m;
		}
		int R = l;
		int ll=-1; int rr=level[lev].size()-1;
		while (ll+1<rr) {
			int mm = (ll+rr)/2;
			if (perm[level[lev][mm]] >= perm[n]) rr=mm;
			else ll=mm;
		}
		int L = rr;

		int overcount = cumxor[lev][R];
		int correction;
		if (L==0) correction = 0;
		else correction = cumxor[lev][L-1];
		int tot = (overcount ^ correction);

		int bits = 0;
		for (int b=0; b<26; b++) {
			if (tot&(1LL<<b)) bits++;
		}
		if (bits >= 2) printf("No\n");
		else printf("Yes\n");
	}
}


#include <cassert>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
#define err(...) fprintf(stderr,__VA_ARGS__)

int N,Q; //Nodes; queries
int par[500001];
char label[500001];
int depth[500001];
vector<int> level[500001];
int lindex[500001]; //Index within its level
vector<int> cumxor[500001];

vector<int> children[500001];
int perm[500001];
int finaldesc[500001];

void traverse(int n, int &i) {
	perm[n] = i++;
	for (int j=0; j<children[n].size(); j++) traverse(children[n][j],i);
	finaldesc[n] = i-1;
}

int main() {
	cin >> N >> Q;
	par[1] = 0;
	depth[1] = 1;
	level[1].push_back(1);
	for (int n=2; n<=N; n++) {
		scanf("%d",par+n);
		children[par[n]].push_back(n);
		depth[n] = depth[par[n]]+1;
		level[depth[n]].push_back(n);
		lindex[n] = level[depth[n]].size()-1;
	}
	string s; cin >> s;
	for (int n=1; n<=N; n++) {
		label[n] = s[n-1];
		cumxor[depth[n]].push_back(1<<(label[n]-'a'));
		int i = lindex[n];
		assert(i == lindex[n]);
		if (i > 0) {
			cumxor[depth[n]][i] ^= cumxor[depth[n]][i-1];
		}
	}

	int i=1;
	traverse(1,i);

	//for (int n=1; n<=N; n++) err("perm[%d]=%d... encompases perm[%d] through perm[%d].\n",n,perm[n],perm[n],finaldesc[n]);

	set<int> ok;
	ok.insert(0);
	for (int i=0; i<26; i++) ok.insert(1<<i);
	for (int q=1; q<=Q; q++) {
		int n,lev; scanf("%d %d",&n,&lev);
		if (level[lev].size() == 0 || perm[level[lev][0]] > finaldesc[n] || perm[level[lev][level[lev].size()-1]] < perm[n]) {
			cout << "Yes" << endl;
			continue;
		}

		//Find largest R such that perm[level[lev][R]] <=  finaldesc[n];
		//Where I interpret perm[level[lev][-1] as -infty and perm[level[lev][size]] as infty
		int l=-1; int r=level[lev].size();
		while (l+1<r) {
			int m = (l+r)/2;
			if (perm[level[lev][m]] <= finaldesc[n]) l=m;
			else r=m;
		}
		int R = l;
		//Find smallest L such that perm[level[l][L]] >= perm[n]
		l=-1; r=level[l].size();
		while (l+1<r) {
			int m = (l+r)/2;
			if (perm[level[lev][m]] >= perm[n]) r=m;
			else l=m;
		}
		int L = r;

		//err("nodes at depth %d: ",lev);
		//for (int i=0; i<level[lev].size(); i++) err("%d ",level[lev][i]);
		//err("Those underneath %d: from %d to %d.\n",n,level[lev][L],level[lev][R]);
		//err("cumxors: "); for (int i=0; i<level[lev].size(); i++) err("%d ",cumxor[lev][i]);

		int overcount = cumxor[lev][R];
		int correction = (L == 0)? 0 : cumxor[lev][L-1];
		int sum = overcount ^ correction;
		//err("Sum: %d ",sum);

		if (ok.count(sum) == 0) printf("No\n");
		else printf("Yes\n");
	}
}