#include <bits/stdc++.h>
using namespace std;
long long Min(long long x, long long y) { return x < y ? x : y; }
long long Max(long long x, long long y) { return x > y ? x : y; }
inline long long R() {
  char c = '!';
  long long x = 0, z = 1;
  for (; c > '9' || c < '0'; c = getchar())
    if (c == '-') z = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * z;
}
const int N = 400010;
int n, m, countt;
char s[N];
int to[N], ne[N], st[N], sl;
int a[N], b[N], p[N];
int h[N][2];
void Ads(int x, int y) {
  to[++sl] = y;
  ne[sl] = st[x];
  st[x] = sl;
}
int main() {
  n = R();
  m = R();
  if (n >= 10000) {
    printf("Yes\n");
    return 0;
  }
  cin >> s;
  for (register int i = n; i >= 1; --i) p[i] = s[i - 1] - 'A';
  for (register int i = 1; i <= m; ++i) {
    int x = R(), y = R();
    a[i] = x;
    b[i] = y;
    h[x][p[y]] = 1;
    h[y][p[x]] = 1;
  }
  int cntt = 0;
  for (register int i = 1; i <= m; ++i) {
    if (!h[a[i]][0]) continue;
    if (!h[a[i]][1]) continue;
    if (!h[b[i]][0]) continue;
    if (!h[b[i]][1]) continue;
    Ads(a[i], b[i]);
    Ads(b[i], a[i]);
    ++cntt;
  }
  for (register int a1 = 1; a1 <= n; ++a1) {
    if (p[a1]) continue;
    for (int i = st[a1]; i; i = ne[i]) {
      int a2 = to[i];
      if (p[a2]) continue;
      if (a2 < a1) continue;
      for (int j = st[a2]; j; j = ne[j]) {
        int a3 = to[j];
        if (!p[a3]) continue;
        for (int k = st[a3]; k; k = ne[k]) {
          int a4 = to[k];
          if (!p[a4]) continue;
          for (int l = st[a4]; l; l = ne[l])
            if (to[l] == a1) {
              printf("Yes\n");
              return 0;
            }
        }
      }
    }
  }
  if (cntt > n / 4 && n > 1000) {
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}
