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

const int maxn = 205000;

int n,m;
int a[maxn];
vector <int> g[maxn];
int um[maxn][2];
int arr[maxn];

void read(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
	char ch = getchar();while(ch != 'A' && ch !='B')ch=getchar();
	a[i]=ch-'A';
    }
    for(int i=1;i<=m;i++){
	int u,v; scanf("%d%d",&u,&v);
	g[u].push_back(v); g[v].push_back(u);
	um[u][a[v]]++; um[v][a[u]]++;
    }
}

queue <int>q;
void work(){
    for(int i=1;i<=n;i++){
	if(um[i][0] == 0 || um[i][1] == 0) q.push(i);
    }
    while(!q.empty()){
	int k = q.front();q.pop();
	if(arr[k] == 1) continue;
	arr[k] = 1;
	for(int i=0;i<g[k].size();i++){
	    um[g[k][i]][a[k]]--;
	    if(um[g[k][i]][a[k]] == 0&&!arr[g[k][i]]){
		q.push(g[k][i]);
	    }
	}
    }
    for(int i=1;i<=n;i++){
	if(!arr[i]){puts("Yes");return;}
    }
    puts("No");
}

int main(){
    read();
    work();
    return 0;
}
