#include <bits/stdc++.h>
using namespace std;
vector<int> G[2 * 100000 + 5];
int dead[200000 + 4];
int neigh[200000 + 3][2];
int N, M;
string S;
int f = 0;
bool check(int v) { return neigh[v][0] > 0 and neigh[v][1] > 0; }
void kill(int v) {
  dead[v] = 1;
  for (int u : G[v]) {
    neigh[u][S[v - 1] - 'A']--;
  }
  for (int u : G[v]) {
    if (dead[u] == 0 and !check(u)) {
      kill(u);
    }
  }
}
int main() {
  cin >> N >> M;
  cin >> S;
  for (int i = 1; i <= M; ++i) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    G[u].push_back(v);
    G[v].push_back(u);
    neigh[u][S[v - 1] - 'A']++;
    neigh[v][S[u - 1] - 'A']++;
  }
  for (int i = 1; i <= N; ++i) {
    if (!check(i)) kill(i);
  }
  for (int i = 1; i <= N; ++i)
    if (dead[i] == 0) f = 1;
  cout << (f ? "Yes" : "No");
}
