#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
char s[200010];
int l, nxt[200010 * 2], head[200010], to[200010 * 2];
int u[200010], U[200010];
bool dfs(int x) {
  if (U[x]) return 1;
  u[x] = 1;
  U[x] = 1;
  bool f1 = 0, f2 = 0;
  for (int i = head[x]; i; i = nxt[i]) {
    int c = to[i];
    bool w = dfs(c);
    if (s[x] != s[c])
      f1 |= w;
    else
      f2 |= w;
  }
  U[x] = 0;
  if (f1 & f2)
    return 1;
  else
    return 0;
}
int main() {
  int n, m;
  n = read();
  m = read();
  scanf("%s", s + 1);
  for (int i = 1; i <= m; i++) {
    int x, y;
    x = read();
    y = read();
    l++;
    nxt[l] = head[x];
    head[x] = l;
    to[l] = y;
    swap(x, y);
    l++;
    nxt[l] = head[x];
    head[x] = l;
    to[l] = y;
  }
  for (int i = 1; i <= n; i++)
    if (dfs(i)) {
      puts("Yes");
      return 0;
    }
  puts("No");
}
