#include <cstdio>
#include <queue>
const int N = 200005;
int n, m, cnt[2][N], head[N], tot, vis[N];
char buf[N];
std::queue<int> q;
struct edge { int to, nxt;} e[ N << 1];
void addedge(int x, int y) {
	e[++tot] = (edge) { y, head[x] }; head[x] = tot;
}
int main() {
	std::scanf("%d%d", &n, &m);
	std::scanf("%s", buf + 1);
	for (int i = 1; i <= m; i++) {
		int x, y;
		std::scanf("%d%d", &x, &y);
		if (x == y) cnt[buf[x] - 'A'][x] = 0x3f3f3f3f;
		else addedge(x, y), addedge(y, x), ++cnt[buf[x] - 'A'][y], ++cnt[buf[y] - 'A'][x];
	}
	for (int i = 1; i <= n; i++) if (!(cnt[0][i] && cnt[1][i])) vis[i] = 1, q.push(i);
	while (!q.empty()) {
		int tmp = q.front(); q.pop();
		for (int i = head[tmp]; i; i = e[i].nxt) if (!vis[e[i].to]) {
			--cnt[buf[tmp] - 'A'][e[i].to];
			if (!(cnt[0][e[i].to] && cnt[1][e[i].to])) vis[e[i].to] = 1, q.push(e[i].to);
		}
	}
	int ans = 1;
	for (int i = 1; i <= n; i++) ans &= vis[i];
	std::puts(ans ? "No" : "Yes");
	return 0;
} 