#include <bits/stdc++.h>
const int N = 2e5 + 10;
const int M = 4e5 + 10;
const char S[] = "AABBA";
int hd[N], nxt[M], to[M], cnt;
char col[N];
int n, m, flag, pos;
inline void adde(int x, int y) {
  cnt++;
  nxt[cnt] = hd[x];
  to[cnt] = y;
  hd[x] = cnt;
}
inline void dfs(int x, int c) {
  if (flag) return;
  if (c == 5) {
    if (x == pos) flag = 1;
    return;
  }
  for (int i = hd[x]; i; i = nxt[i]) {
    if (col[to[i]] == S[c]) dfs(to[i], c + 1);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", col + 1);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    adde(x, y);
    adde(y, x);
  }
  for (int i = 1; i <= n; ++i) {
    if (col[i] == 'A') {
      pos = i;
      dfs(i, 1);
    }
    if (flag) break;
  }
  printf(flag ? "Yes" : "No");
  return 0;
}
