#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
vector<int> g[N];
char s[N];
bool ban[N];
int d[N], fa[N], vis[N];
bool fl = 0;
int cnt;
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void unite(int x, int y) {
  if (find(x) != find(y)) fa[find(x)] = find(y);
}
void dfs(int x) {
  vis[x] = 1;
  if (s[x] == 'B' && ban[x]) fl = 1;
  for (size_t j = 0; j < g[x].size(); j++)
    if (!vis[g[x][j]]) dfs(g[x][j]);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i)
    if (s[i] == 'B') {
      for (int j = 0; j < g[i].size(); ++j) ban[i] |= (s[g[i][j]] == 'B');
    }
  for (int i = 1; i <= n; ++i)
    if (s[i] == 'A') {
      fl = 0;
      for (int j = 0; j < g[i].size(); ++j)
        if (s[g[i][j]] == 'A') fl = 1;
      if (!fl) break;
      fl = 0;
      dfs(i);
      if (fl == 1) {
        cnt = 1;
        break;
      }
    }
  if (cnt == 1)
    puts("Yes");
  else
    puts("No");
}
