#include <cstdio>
#define V_MAX 200000
#define E_MAX 200000
struct edg
{
	int v; edg * e;
} ES[E_MAX * 2], * ER = ES, * EA[V_MAX + 1];
inline void edg_ins(int u, int v)
{
	*ER = (edg) {v, EA[u]}, EA[u] = ER++;
	*ER = (edg) {u, EA[v]}, EA[v] = ER++;
}
int V, E, u, v, k, d[V_MAX + 1][2], Ql, Qr, Q[V_MAX + 1];
char s[V_MAX + 2];
int main()
{
	scanf("%d %d", &V, &E);
	scanf(" %s", s + 1);
	while (E--)
		scanf("%d %d", &u, &v), edg_ins(u, v), ++d[u][s[v] - 'A'], ++d[v][s[u] - 'A'];
	for (u = 1; u <= V; ++u)
		if (!d[u][0] || !d[u][1])
			Q[++Qr] = u;
	while (Ql < Qr)
	{
		u = Q[++Ql], k = s[u] - 'A', --V;
		for (edg * e = EA[u]; e; e = e->e)
			if (!--d[e->v][k] && d[e->v][k ^ 1])
				Q[++Qr] = e->v;
	}
	puts(V ? "Yes" : "No");
	return 0;
}