#include <bits/stdc++.h>
using namespace std;
long long dx[] = {0, 1, 0, -1};
long long dy[] = {-1, 0, 1, 0};
string s;
bool rp[200009], o_rp[200009];
bool ban[200009], used[200009];
long long col[200009], c;
long long x, y, n, m;
vector<long long> v[200009];
void H_E() {
  cout << "Yes" << endl;
  exit(0);
}
void dfs(long long x) {
  used[x] = 1;
  col[x] = c;
  for (long long i = 0; i < v[x].size(); i++) {
    if (!used[v[x][i]] && !ban[v[x][i]]) {
      if (s[v[x][i]] == s[x]) {
        dfs(v[x][i]);
      }
    }
  }
}
void dfs2(long long x, long long pre) {
  if (used[x]) H_E();
  used[x] = 1;
  for (long long i = 0; i < v[x].size(); i++) {
    long long nex = v[x][i];
    if (nex != x && nex != pre) {
      if (!ban[nex]) {
        dfs2(nex, x);
      }
    }
  }
}
set<pair<long long, long long> > st;
signed main() {
  cin >> n >> m;
  cin >> s;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    if (st.count(pair<long long, long long>(x, y))) continue;
    st.insert(pair<long long, long long>(x, y));
    st.insert(pair<long long, long long>(y, x));
    v[x].push_back(y);
    v[y].push_back(x);
    if (x == y) rp[x] = 1;
  }
  for (long long i = 0; i < n; i++)
    if (rp[i]) {
      for (long long j = 0; j < v[i].size(); j++) {
        if (s[i] != s[v[i][j]]) o_rp[v[i][j]] = 1;
      }
    }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < v[i].size(); j++) {
      if (rp[i] && rp[v[i][j]]) {
        if (s[i] != s[v[i][j]]) H_E();
      }
      if (o_rp[i] && o_rp[v[i][j]]) {
        if (s[i] == s[v[i][j]]) H_E();
      }
    }
  }
  while (1) {
    long long ss = 0;
    for (long long i = 0; i < n; i++)
      if (!ban[i]) {
        long long sum = 0;
        for (long long j = 0; j < v[i].size(); j++) {
          if (ban[v[i][j]]) continue;
          if (s[v[i][j]] == 'A')
            sum |= (1 << 0);
          else
            sum |= (1 << 1);
        }
        if (sum != 3) ban[i] = 1, ss++;
      }
    if (!ss) break;
  }
  for (long long i = 0; i < n; i++)
    if (!ban[i]) {
      dfs2(i, -1);
      break;
    }
  cout << "No" << endl;
}
