#include <bits/stdc++.h>
using namespace std;
const int N = 200005, M = 1000005;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) g = g * 10 + ch - '0';
  return f * g;
}
int n, m, a[N][2], h[N * 2];
int size, fir[N * 2], cnt;
struct edge {
  int u, v, nex;
} e[M];
void add(int u, int v) {
  e[++size] = (edge){u, v, fir[u]};
  fir[u] = size;
}
char col[N];
bool work(int x) {
  if (h[x] == 1)
    return true;
  else if (h[x] == 2)
    return false;
  h[x] = 1;
  for (int i = fir[x]; i; i = e[i].nex)
    if (work(e[i].v)) return true;
  h[x] = 2;
  return false;
}
int main() {
  scanf("%d %d", &n, &m);
  scanf(" %s", col + 1);
  for (int i = 1; i <= n; i++) {
    a[i][0] = ++cnt;
    a[i][1] = ++cnt;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (col[u] == col[v]) {
      add(a[u][0], a[v][1]);
      add(a[v][0], a[u][1]);
    } else {
      add(a[u][1], a[v][0]);
      add(a[v][1], a[u][0]);
    }
  }
  for (int i = 1; i <= cnt; i++)
    if (!h[i]) {
      if (work(i)) {
        puts("Yes");
        return 0;
      }
    }
  puts("No");
  return 0;
}
