#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int rd() {
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * w;
}
int to[N << 1], nt[N << 1], hd[N], dg[N], tot = 1;
void adde(int x, int y) {
  ++tot, to[tot] = y, nt[tot] = hd[x], hd[x] = tot, ++dg[x];
  ++tot, to[tot] = x, nt[tot] = hd[y], hd[y] = tot, ++dg[y];
}
int qto[N], qnt[N], qhd[N], qt = 1;
void addq(int x, int y) { ++qt, qto[qt] = y, qnt[qt] = qhd[x], qhd[x] = qt; }
char cc[N];
int n, m, de[N], fa[N], fe[N], zz[N];
bool cr[N], mk[N], vs[N], v0[N], v1[N];
map<int, int> ap[N];
int main() {
  n = rd(), m = rd();
  scanf("%s", cc + 1);
  for (int i = 1; i <= m; ++i) {
    int x = rd(), y = rd();
    if (x == y)
      cr[x] = 1;
    else if (!ap[x].count(y))
      ap[x][y] = ap[y][x] = 1, adde(x, y);
  }
  for (int i = 2; i <= tot; i += 2) {
    int x = to[i], y = to[i | 1];
    if (cr[x] && cr[y] && cc[x] != cc[y]) {
      puts("Yes");
      return 0;
    }
    if (dg[x] > dg[y] || (dg[x] == dg[y] && x > y)) swap(x, y);
    addq(x, y);
  }
  for (int x = 1; x <= n; ++x) {
    for (int i = hd[x]; i; i = nt[i]) zz[to[i]] = i;
    for (int i = hd[x]; i; i = nt[i]) {
      int y = to[i];
      for (int j = hd[y]; j; j = nt[j]) {
        int z = to[j];
        if (zz[z]) {
          int k = zz[z];
          if (cc[x] == 'A')
            v0[j >> 1] = 1;
          else
            v1[j >> 1] = 1;
          if (cc[y] == 'A')
            v0[k >> 1] = 1;
          else
            v1[k >> 1] = 1;
          if (cc[z] == 'A')
            v0[i >> 1] = 1;
          else
            v1[i >> 1] = 1;
        }
      }
    }
    for (int i = hd[x]; i; i = nt[i]) zz[to[i]] = 0;
  }
  queue<int> q;
  for (int i = 1; i <= n; ++i)
    if (!vs[i]) {
      vs[i] = 1, q.push(i);
      while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (int i = hd[x]; i; i = nt[i]) {
          int y = to[i];
          if (!vs[y])
            fa[y] = x, fe[y] = i >> 1, de[y] = de[x] + 1,
            mk[i >> 1] = vs[y] = 1, q.push(y);
        }
      }
    }
  for (int i = 2; i <= tot; i += 2) {
    if (mk[i >> 1]) continue;
    int x = to[i], y = to[i | 1];
    if (de[x] < de[y]) swap(x, y);
    if (fa[x] == fa[y]) {
      int z = fa[x];
      int j = fe[x], k = fe[y];
      if (cc[x] != cc[y] && cc[x] != cc[z]) {
        if ((cc[x] == 'A' ? v0[j] : v1[j]) || cr[x]) {
          puts("Yes");
          return 0;
        }
      }
      if (cc[y] != cc[x] && cc[y] != cc[z]) {
        if ((cc[y] == 'A' ? v0[k] : v1[k]) || cr[y]) {
          puts("Yes");
          return 0;
        }
      }
      if (cc[z] != cc[x] && cc[z] != cc[y]) {
        if ((cc[z] == 'A' ? v0[j] || v0[k] : v1[j] || v1[k]) || cr[z]) {
          puts("Yes");
          return 0;
        }
      }
    } else if (fa[fa[x]] == fa[y]) {
      int z = fa[x], w = fa[y];
      int sm = (cc[x] - 'A') + (cc[y] - 'A') + (cc[z] - 'A') + (cc[w] - 'A');
      if (sm == 2 && (cc[x] == cc[y] || cc[x] == cc[z])) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}
