#include <bits/stdc++.h>
using namespace std;
long long n, m, AB[200006];
string ss;
long long vis[200006], can[200006];
vector<long long> v[200006];
bool dfs(long long x) {
  vis[x] = 1;
  can[x] = 1;
  long long a = 0, b = 0;
  for (auto i : v[x]) {
    if (vis[i] && can[i]) {
      if (AB[i] == 0)
        a++;
      else
        b++;
      continue;
    }
    if (dfs(i)) {
      a += ((AB[i] == 0) ? 1 : 0);
      b += ((AB[i] == 1) ? 1 : 0);
    }
  }
  if (a >= 1 && b >= 1)
    can[x] = 1;
  else
    can[x] = 0;
  return can[x];
}
int main() {
  cin >> n >> m >> ss;
  for (long long i = 0; i < ss.length(); i++)
    AB[i + 1] = ((ss[i] == 'A') ? 0 : 1);
  for (long long i = 0; i < m; i++) {
    long long n1, n2;
    cin >> n1 >> n2;
    if (n1 == n2) {
      v[n1].push_back(n2);
      continue;
    }
    v[n1].push_back(n2);
    v[n2].push_back(n1);
  }
  for (long long i = 1; i <= n; i++) {
    v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
  }
  for (long long i = 1; i <= n; i++) {
    if (can[i]) {
      cout << "Yes\n";
      return 0;
    }
    if (vis[i]) continue;
    if (dfs(i)) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}
