#include<vector>
#include<cstdio>
#include<queue>
#include<algorithm>
#define MN 410001
using namespace std;

int n,m,x[MN],bo[MN][2],y[MN],ln;
char s[MN];
vector <int> v[MN];
bool B[MN];
queue<int> q;
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) s[i]=s[i]=='B',B[i]=1;
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x[i],&y[i]);
		v[x[i]].push_back(y[i]);
		v[y[i]].push_back(x[i]);
		bo[x[i]][s[y[i]]]++;bo[y[i]][s[x[i]]]++;
	}
	for (int i=1;i<=n;i++)
	if (!bo[i][0]||!bo[i][1]) q.push(i),B[i]=0;
	while (!q.empty()){
		ln++;
		int k=q.front();q.pop();
		for (int i=0;i<v[k].size();i++)
		if (--bo[v[k][i]][s[k]]==0&&B[v[k][i]]) q.push(v[k][i]),B[v[k][i]]=0;
	}
	puts(ln==n?"No":"Yes");
} 