#include <bits/stdc++.h>
using namespace std;
const int MN = 200010;
int N, M;
string s;
vector<int> g[MN];
bool f[2][15][MN];
int main() {
  cin >> N >> M >> s;
  for (int i = 0; i < (M); i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < (N); i++) {
    int c = s[i] == 'A';
    f[c][0][i] = 1;
  }
  for (int i = 0; i < (14); i++) {
    for (int j = 0; j < (N); j++) {
      int st = 0;
      for (int to : g[j]) {
        if (f[0][i][to]) {
          st |= 1;
        }
        if (f[1][i][to]) {
          st |= 2;
        }
      }
      int c = s[j] == 'A';
      if (st == 3 && f[c][i][j]) {
        f[c][i + 1][j] = 1;
      }
    }
  }
  int st = 0;
  for (int i = 0; i < (N); i++) {
    if (f[0][14][i]) {
      st |= 1;
    }
    if (f[1][14][i]) {
      st |= 2;
    }
  }
  puts(st == 3 ? "Yes" : "No");
  return 0;
}
