#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> mat[200010];
string str;
int col[200010];
pair<int, int> getVal(int u, int v) {
  if (u > v) swap(u, v);
  return make_pair(u, v);
}
int rec(int p, int root, int ty) {
  if (col[root] != 1) return 0;
  int temp = 0;
  if (ty == 0) {
    for (auto x : mat[p])
      if (col[x] == 1 && !temp) temp = max(temp, rec(x, root, 1));
  } else if (ty == 1) {
    for (auto x : mat[p])
      if (col[x] == 2 && !temp) temp = max(temp, rec(x, root, 2));
  } else if (ty == 2) {
    for (auto x : mat[p])
      if (col[x] == 2 && !temp) temp = max(temp, rec(x, root, 3));
  } else if (ty == 2) {
    for (auto x : mat[p])
      if (x == root) temp = 1;
  }
  return temp;
}
int main() {
  ios::sync_with_stdio(false);
  int a, b;
  cin >> n >> m;
  cin >> str;
  for (int i = 0; i <= n - 1; i++) {
    int x = str[i] - 'A';
    x++;
    col[i + 1] = x;
  }
  for (int i = 0; i <= m - 1; i++) {
    cin >> a >> b;
    mat[a].push_back(b);
    mat[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (rec(i, i, 0)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}
