#include <bits/stdc++.h>

int N, M;
std::vector <int> edge[210000];
char s[210000];
int cnt[210000][2];
int vis[210000];

int main () {
  std::ios::sync_with_stdio (0);
  std::cin >> N >> M;
  for (int i = 0; i < N; ++i) std::cin >> s[i];
  for (int i = 0; i < M; ++i) {
    int u, v; std::cin >> u >> v; --u; --v;
    edge[u].push_back (v); cnt[u][s[v] - 'A']++;
    edge[v].push_back (u); cnt[v][s[u] - 'A']++;
  }
  std::queue <int> q;
  for (int i = 0; i < N; ++i) if (!cnt[i][0] || !cnt[i][1]) q.push (i), vis[i] = true;
  while (!q.empty ()) {
    int n = q.front (); q.pop ();
    for (int i : edge[n])
      if (!--cnt[i][s[n] - 'A'] && !vis[i]) q.push (i), vis[i] = true;
  }
  for (int i = 0; i < N; ++i) if (!vis[i]) {
    std::cout << "Yes\n"; return 0;
  }
  std::cout << "No\n";
}
