#include <bits/stdc++.h>
using namespace std;
 
typedef double lf; typedef long long ll; typedef vector<ll> vll; typedef long double llf; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef unsigned int uint; typedef pair<int, int> pii; typedef unsigned long long ull;
 
bool Dbg;
const int mod = 998244353, MAXN = 1e5 + 7, inft = 1e9 + 7; const ll infl = llf(1e18) + 1;
const llf eps = 1e-7;
 
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define mid ((l+r)>>1)
//ans = mid, l = mid+1
#define Debug(x) (Dbg ? void(cerr << #x << " = " << x << ' ') : void())
#define debug(...) (Dbg ? (fprintf(stderr, __VA_ARGS__)) : 0)
#define lop(i,a,b) for(int i = (a), i##end = (b); i <= i##end; ++i)
//toposort
#define dlop(i,a,b) for(int i = (a), i##end = (b); i >= i##end; --i)
#define ergo(a) for(__typeof((a).end())it = (a).begin(), it##end = (a).end(); it != it##end; ++it)
 
template<typename T> inline T sqr(T x) {return x * x; }
template<typename T> inline T abs(T x) {return x >= 0 ? x : -x; }
template<typename A, typename B> inline A gcd(A a, B b) {if (a < b) swap(a, b); if (!b) return a; while (A t = a % b) a = b, b = t; return b; }
template<typename A, typename B> inline A lcm(A a, B b) {return a / gcd(a, b) * b; }
template<typename A, typename B> inline A Pow(A a, B b, int mod) {A ret; for (ret = 1; b; b >>= 1) {if (b & 1) ret = ret * 1ll * a % mod; a = a * 1ll * a % mod; } return ret % mod; }
template<typename A, typename B> inline A max(A a, B b) {return a > b ? a : b; } template<typename A, typename B> inline A min(A a, B b) {return a < b ? a : b; } template<typename A, typename B> inline void chmax(A &x, B y) {if (x < y) x = y; } template<typename A, typename B> inline void chmin(A &x, B y) {if (x > y) x = y; } template<typename A, typename B> inline void amod(A &x, B y) {x += y; while (x < 0) x += mod; while (x > mod) x -= mod; }
 
struct IO {
#define IS(x) (x == 10 || x == 13 || x == ' ')
#define OP operator
#define RT return *this
#define RX x=0;int t=P();while((t<'0'||t>'9')&&t!='-')t=P();f=1;\
  if(t=='-')t=P(),f=-1;x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define RU x=0;int t=P();while(t<'0'||t>'9')t=P();x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define TR *this,x;return x
#define WI if(x){if(x<0)P('-'),x=-x;c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
#define WU if(x){c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
  struct Cg {inline int operator()() {return getchar(); } }; struct Cp {inline void operator()(int x) {putchar(x); } }; template<typename T>struct Fr {int f; T P; inline Fr&OP, (int&x) {RX; x *= f; RT; } inline Fr&OP, (ll &x) {RX; x *= f; RT; } inline Fr&OP, (char&x) {for (x = P(); IS(x); x = P()); RT; } inline Fr&OP, (string&x) {cin >> x; RT; } inline Fr&OP, (char*x) {char t = P(); for (; IS(t); t = P()); if (~t) {for (; !IS(t) && ~t; t = P()) * x++ = t; }*x++ = 0; RT; } inline Fr&OP, (lf&x) {scanf("%lf", &x); RT; } inline Fr&OP, (llf&x) {lf y; scanf("%lf", &y); x = y; RT; } inline Fr&OP, (uint&x) {RU; RT; } inline Fr&OP, (ull&x) {RU; RT; } }; Fr<Cg>in; template<typename T>struct Fw {int c, s[24]; T P; inline Fw&OP, (int x) {WI; RT; } inline Fw&OP, (uint x) {WU; RT; } inline Fw&OP, (ll x) {WI; RT; } inline Fw&OP, (ull x) {WU; RT; } inline Fw&OP, (char x) {P(x); RT; } inline Fw&OP, (lf x) {printf("%.5lf", x); RT; } inline Fw&OP, (llf x) {printf("%.5lf", lf(x)); RT; } inline Fw&OP, (const string &x) {ergo(x) P(*it); RT; } inline Fw&OP, (const char*x) {while (*x)P(*x++); RT; } }; Fw<Cp>out;
} io;
#define in io.in
#define out io.out
//fread float
 
vector<int>G[MAXN << 1];
int n, m, deg[MAXN << 1][2], topo[MAXN<<1];
bool col[MAXN << 1], vis[MAXN<<1];
inline void add(int u, int v) {
  G[u].pb(v), G[v].pb(u);
  ++deg[v][col[u]], ++deg[u][col[v]];
}
 
int main() {
#ifdef LOCAL_DEBUG
  // freopen("data.in", "r", stdin), freopen("data.out", "w", stdout);
  Dbg = 1;
  uint tim1 = clock();
#endif
  in, n, m;
  lop(i, 1, n) {
    char s; in, s;
    if (s == 'B') col[i] = 1;
  }
  while (m--) {
    int u, v;
    in, u, v;
    add(u, v);   
  }
  int cnt = 0;
  lop(i,1,n) if (!deg[i][0] || !deg[i][1]) topo[++cnt] = i, vis[i] = 1;//vis防止入队两次
  for(int i = 1; i <= cnt; ++i) {
    ergo(G[topo[i]]) {
      if (--deg[*it][col[topo[i]]] == 0 && !vis[*it]) topo[++cnt] = *it, vis[*it] = 1;
    }
  }
  puts(cnt == n ? "No" : "Yes");
 
#ifdef LOCAL_DEBUG
  fprintf(stderr, "\ntime:%.5lfms", (clock() - tim1) / (1.0 * CLOCKS_PER_SEC) * 1000);
#endif
  return 0;
}

Measured memory_bytes: 12928