#include <bits/stdc++.h>

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 2e5 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n, m;
char type[N];
int ok[N][2];

bool bad[N];
vector <int> G[N];

int main(){
	scanf("%d %d", &n, &m);
	scanf("%s", type + 1);

	for(int i = 1; i <= m; ++i){
		int u, v;
		scanf("%d %d", &u, &v);
		
		ok[u][type[v] - 'A']++;
		ok[v][type[u] - 'A']++;

		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	queue <int> Q;
	for(int i = 1; i <= n; ++i)
		if(ok[i][0] == 0 || ok[i][1] == 0){
			bad[i] = true;
			Q.push(i);
		}
	
	while(!Q.empty()){
		int u = Q.front();
		Q.pop();
		
		for(int v: G[u]){
			if(bad[v])
				continue;
			
			ok[v][type[u] - 'A']--;
			if(ok[v][0] == 0 || ok[v][1] == 0){
				bad[v] = true;
				Q.push(v);
			}
		}
	}
	
	for(int i = 1; i <= n; ++i)
		if(!bad[i]){
			puts("Yes");
			return 0;
		}
	
	puts("No");
	return 0;
}