#include <cstdio>

#define maxn 200010
struct Edge {
	Edge *next;
	int to;
} *last[maxn], e[maxn << 1], *ecnt = e;
char s[maxn];
int cnt[maxn][2];
inline void link(int a, int b)
{
	++cnt[b][s[a] == 'B'];
	*++ecnt = (Edge) {last[a], b}; last[a] = ecnt;
}
bool del[maxn];
int q[maxn];
int main()
{
	int n, m; scanf("%d%d", &n, &m); scanf("%s", s + 1);
	for (int i = 1; i <= m; ++i)
	{
		int a, b; scanf("%d%d", &a, &b);
		link(a, b); link(b, a);
	}
	int head = 0, tail = 0;
	for (int i = 1; i <= n; ++i) if (!cnt[i][0] || !cnt[i][1]) del[q[++tail] = i] = 1;
	while (head < tail)
	{
		int now = q[++head];
		for (Edge *iter = last[now]; iter; iter = iter -> next)
		{
			--cnt[iter -> to][s[now] == 'B'];
			if (!del[iter -> to] && !cnt[iter -> to][s[now] == 'B']) del[q[++tail] = iter -> to] = 1;
		}
	}
	puts(tail == n ? "No" : "Yes");
	return 0;
}