#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
using namespace std;
const int N = 2e5 + 10;
char s[N];
vector<int> g[N];
bool f = false;
bool vis[N];
void dfs(int u, int cnt) {
  if (f) return;
  if (cnt == 4) {
    puts("Yes");
    f = true;
    return;
  }
  vis[u] = true;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (cnt == 0) {
      if (s[v - 1] == 'A') dfs(v, cnt + 1);
    } else if (cnt == 2) {
      if (s[v - 1] == 'B') dfs(v, cnt + 1);
    } else if (cnt == 1) {
      if (s[v - 1] == 'B' && !vis[v]) dfs(v, cnt + 1);
    } else if (cnt == 3) {
      if (s[v - 1] == 'A' && vis[v]) dfs(v, cnt + 1);
    }
  }
}
int main() {
  int n, m, u, v;
  scanf("%d %d", &n, &m);
  scanf("%s", s);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == 'A') dfs(i, 0);
    if (f) break;
  }
  if (!f) puts("No");
  return 0;
}
