#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
int n, m;
vector<int> g[N];
bool ok[N], col[N], del[N];
int a[2][N], used[N];
queue<int> q;
string ans[2] = {"No", "Yes"};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  string second;
  cin >> second;
  for (int i = 1; i <= n; i++) col[i] = second[i - 1] == 'B';
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    if (x == y) {
      ok[x] = 1;
      a[col[x]][x]++;
    } else {
      a[col[y]][x]++;
      a[col[x]][y]++;
      g[x].push_back(y);
      g[y].push_back(x);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!(a[0][i] && a[1][i])) {
      q.push(i);
      del[i] = 1;
    }
  }
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < (int((g[v]).size())); i++) {
      int to = g[v][i];
      if (!del[to]) {
        a[col[v]][to]--;
        if (!(a[0][to] && a[1][to])) {
          del[to] = 1;
          q.push(to);
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    cnt += !del[i];
  }
  cout << ans[cnt > 0] << "\n";
  return 0;
}
