#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
struct edge {
  int v, nxt;
} g[N << 1];
int tot = 0, head[N];
inline void add(int u, int v) {
  g[++tot] = edge{v, head[u]};
  head[u] = tot;
  g[++tot] = edge{u, head[v]};
  head[v] = tot;
}
int n, m;
char s[N];
inline void dfs(int S, int u, int x) {
  for (int i = head[u]; i; i = g[i].nxt) {
    int v = g[i].v;
    if (v == S && x == 4) {
      puts("Yes");
      exit(0);
    } else if (s[v - 1] == 'A' && x == 1)
      dfs(S, v, x + 1);
    else if (s[v - 1] == 'B' && (x == 2 || x == 3))
      dfs(S, v, x + 1);
  }
}
int main() {
  scanf("%d%d%s", &n, &m, s);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
  }
  for (int i = 1; i <= n; ++i)
    if (s[i - 1] == 'A') dfs(i, i, 1);
  puts("No");
  return 0;
}
