import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;
immutable long INF = 1L << 59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto S = readln.chomp.map!(a => a == 'B').array;
    auto G = new int[][](N);
    auto H = new bool[int][](N);
    auto uf = new UnionFind(N);

    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        auto u = s[0] - 1;
        auto v = s[1] - 1;
        G[u] ~= v;
        G[v] ~= u;
        if (S[u] == S[v]) {
            uf.unite(u, v);
        }
    }

    foreach (i; 0..N) {
        foreach (j; G[i]) {
            H[uf.find(i)][uf.find(j)] = true;
        }
    }

    foreach (i; 0..N) {
        if (i !in H[i]) continue;
        foreach (j; H[i]) {
            if (j != i && j in H[j]) {
                writeln("Yes");
                return;
            }
        }
    }

    writeln("No");
}

class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}
