// Solution to ADAAPPLE SPOJ

#include <iostream>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <climits>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;
 
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define prec(n) fixed << setprecision(n)


// max number of nodes
const int mxN = 3e5+10;

// Adjecency list
vector<int> adj[mxN];

// n-> nodes
// q-> queries
// c-> will be used to count inTime and outTime of a node
int n,q,c;

// st-> stores InTime of a node in DFS
// en-> stores outTime of a node in DFS
int st[mxN],en[mxN];

// t-> To make a segment tree
int t[mxN<<2];

// Binary lifting (For LCA)
int h[mxN][20];

// Depth of a node
int d[mxN];

// Values of nodes i.e. which owner does it belong
string s;


// DFS 
// u-> current node
// p-> parent node
// hi-> current height
void dfs(int u=0,int p=-1,int hi=0){
    // Store parent
    h[u][0]=p;

    // height
    d[u]=hi;

    // store that node's owner (Either 0/1)  in seg tree to cal range sum
    t[2*n+c]=s[u]-'0';

    // InTime...
    st[u]=c++;


    for(auto k:adj[u]){
        if(k==p) continue;
        dfs(k,u,hi+1);
    }

    /* Let tour be 1 2 3 3 4 4 2 1 
        sum of path from node 1->4
        range sum [0,4] (3 will be removed as + - stored at intime and outtime)
        -val stored at outtime
    */
    t[2*n+c]=-(s[u]-'0');

    // outTime
    en[u]=c++;
}

void build(){
    // Building seg tree for range sum
    for(int i=2*n-1;i>0;i--){
        t[i]=t[i<<1]+t[(i<<1)|1];
    }
}

void update(int pos,int val){
    // Modification operation in seg tree
    for(t[pos+=2*n]=val;pos>1;pos>>=1){
        t[pos>>1]=t[pos]+t[pos^1];
    }
}

int query(int l,int r){
    // Range sum from [l,r] (Including L and excluding R)
    int ans=0;
    for(l+=2*n,r+=2*n;l<r;l>>=1,r>>=1){
        if(l&1) ans+=t[l++];
        if(r&1) ans+=t[--r];
    }
    return ans;
}

int pathLength(int a,int b){
    // Calculates number of nodes on path between any two nodes... using LCA
    if(d[a] < d[b]) swap(a,b);
    int diff=d[a]-d[b],temp=a;
    for(int i=19;i>=0;i--){
        if(diff&(1ll<<i)) a=h[a][i];
    }
    if(a==b) return diff+1;
    for(int i=19;i>=0;i--){
        if(h[a][i]!=h[b][i]){
            a=h[a][i];
            b=h[b][i];
        }
    }
    return d[b]+d[temp]-2*d[h[a][0]]+1;
}

void solve(){
    cin >> n >> q;
    cin >> s;
    for(int i=0;i<n;i++){
        adj[i].clear();
        st[i]=0;
    }
    for(int i=1,u,v;i<n;i++){
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    c=0;

    // DFS
    dfs();

    // Sparse Matrix
    for(int i=1;i<20;i++){
        for(int j=0;j<n;j++){
            if(h[j][i-1]!=-1) h[j][i]=h[h[j][i-1]][i-1];
            else h[j][i]=-1;
        }
    }

    // Building seg tree
    build();
    while(q--){
        int t;
        cin >> t;
        if(t){
            int a,b;
            cin >> a >> b;
            if(st[a] > st[b]) swap(a,b);
            
            // Check is range sum of path from (a,b)
            int check=query(st[a],st[b]+1);

            // Len is number of nodes in path (a,b)
            int len=pathLength(a,b);


            // Two main possibility if all nodes are 0 or all nodes are 1
            // So check can be equal to len or 0
            // IF so then "YES"
            // Else "NO"
            if(check==len || check==0){
                cout << "YES\n";
            }
            else{
                cout << "NO\n";
            }
        }
        else{
            int a;
            cin >> a;
            s[a]='1'-s[a]+'0';
            // Update value at st[a] as owner changed (+)
            update(st[a],s[a]-'0');

            // Update value at en[a] as owner changed (-)
            update(en[a],-(s[a]-'0'));
        }
    }
}
 
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("error.txt","w",stderr);
        freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t=1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
 
// And curtains...ssa