#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<vector<int>> adj(n), degree(2, vector<int> (n));
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    ++degree[s[x] - 'A'][y];
    ++degree[s[y] - 'A'][x];
  }
  vector<bool> visit(n);
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    if (!degree[0][i] || !degree[1][i]) {
      q.push(i);
      visit[i] = true;
    }
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto y : adj[x]) {
      if (!visit[y] && !--degree[s[x] - 'A'][y]) {
        q.push(y);
        visit[y] = true;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!visit[i]) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}
