#include <bits/stdc++.h>
using namespace std;
int n, m, a[200000], b[200000];
char s[200001];
vector<int> e[200000];
int ok[200000];
bool dfs(int x, int before, int counter) {
  if (ok[x] == -1) return false;
  if (ok[x] == 1 && counter >= 2 * n) return true;
  counter++;
  ok[x] = 1;
  for (int i = 0; i < e[x].size(); i++) {
    if (before & 1) {
      if (s[e[x][i]] != s[x])
        if (dfs(e[x][i], 2, counter)) return true;
      ;
    }
    if (before & 2) {
      if (s[e[x][i]] == s[x])
        if (dfs(e[x][i], 1, counter)) return true;
      ;
    }
  }
  ok[x] = -1;
  return false;
}
int main() {
  scanf("%d%d%s", &n, &m, s);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    a[i]--;
    b[i]--;
    e[a[i]].push_back(b[i]);
    e[b[i]].push_back(a[i]);
  }
  for (int i = 0; i < n; i++) ok[i] = 0;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    if (dfs(i, 3, 0)) {
      flag = true;
      break;
    }
  }
  if (flag)
    printf("Yes\n");
  else
    printf("No\n");
}
