#include <bits/stdc++.h>
using namespace std;
long long n, m;
string s;
vector<long long> adj[200005];
long long visited[200005];
bool flag = false;
void add_edge(long long a, long long b) {
  adj[a].push_back(b);
  adj[b].push_back(a);
}
void adfs(long long node, long long height, long long val, string str) {
  if (height == 5) {
    if (node == val) {
      if (str == "AABB" || str == "BBAA") {
        flag = true;
      }
    }
    return;
  }
  str.push_back(s[node - 1]);
  visited[node] = val;
  for (long long i = 0; i < adj[node].size(); i++)
    adfs(adj[node][i], height + 1, val, str);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n >> m >> s;
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    add_edge(u, v);
  }
  for (long long i = 1; i <= n; i++) {
    string str;
    adfs(i, 1, i, str);
    if (flag) break;
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
