#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
vector<int> g[N];
bool ok[N];
int col[N], used[N];
int n, m;
bool ans;
int cnt[N];
bool check4(int x) {
  used[x] = 1;
  for (int i = 0; i < (int((g[x]).size())); i++) {
    int y = g[x][i];
    for (int j = 0; j < (int((g[y]).size())); j++) {
      int z = g[y][j];
      if (x == z) continue;
      cnt[z] = 0;
    }
  }
  for (int i = 0; i < (int((g[x]).size())); i++) {
    int y = g[x][i];
    if (col[y] == col[x] ^ 1) {
      for (int j = 0; j < (int((g[y]).size())); j++) {
        int z = g[y][j];
        if (x == z) continue;
        if (col[y] == col[z]) {
          cnt[z] = 1;
        }
      }
    }
  }
  for (int i = 0; i < (int((g[x]).size())); i++) {
    int y = g[x][i];
    if (col[y] == col[x]) {
      for (int j = 0; j < (int((g[y]).size())); j++) {
        int z = g[y][j];
        if (x == z) continue;
        if (col[y] == col[z] ^ 1) {
          if (cnt[z] == 1) return true;
        }
      }
    }
  }
  for (int i = 0; i < (int((g[x]).size())); i++) {
    int y = g[x][i];
    for (int j = 0; j < (int((g[y]).size())); j++) {
      int z = g[y][j];
      if (x == z) continue;
      cnt[z] = 0;
    }
  }
  bool res = false;
  for (int i = 0; i < (int((g[x]).size())); i++) {
    int y = g[x][i];
    if (!used[y]) {
      res |= check4(y);
      if (res) return res;
    }
  }
  return res;
}
bool check3(int x) {
  used[x] = 1;
  for (int i = 0; i < (int((g[x]).size())); ++i) {
    int y = g[x][i];
    cnt[y] = 1;
  }
  if (ok[x]) {
    for (int i = 0; i < (int((g[x]).size())); i++) {
      int y = g[x][i];
      if (col[x] == col[y] ^ 1) {
        for (int j = 0; j < (int((g[y]).size())); j++) {
          int z = g[y][j];
          if (x == z) continue;
          if (col[z] == col[y] && cnt[z]) {
            return true;
          }
        }
      }
    }
  }
  for (int i = 0; i < (int((g[x]).size())); ++i) {
    int y = g[x][i];
    cnt[y] = 0;
  }
  bool res = false;
  for (int i = 0; i < (int((g[x]).size())); i++) {
    int y = g[x][i];
    if (!used[y]) {
      res |= check3(y);
      if (res) return res;
    }
  }
  return res;
}
bool check2(int x) {
  used[x] = 1;
  for (int i = 0; i < (int((g[x]).size())); i++) {
    int y = g[x][i];
    if (ok[x] && ok[y] && col[x] == col[y] ^ 1) return true;
  }
  bool res = false;
  for (int i = 0; i < (int((g[x]).size())); i++) {
    int y = g[x][i];
    if (!used[y]) {
      res |= check2(y);
      if (res) return res;
    }
  }
  return res;
}
int main() {
  cin >> n >> m;
  string second;
  cin >> second;
  for (int i = 1; i <= n; i++) col[i] = second[i - 1] == 'B';
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    ok[x] |= x == y;
    if (x != y) {
      g[x].push_back(y);
      g[y].push_back(x);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      ans |= check4(i);
      if (ans) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  memset(used, 0, sizeof used);
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      ans |= check3(i);
      if (ans) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  memset(used, 0, sizeof used);
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      ans |= check2(i);
      if (ans) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  if (ans)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
