import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto nm = aryread;
    auto s = sread();
    auto graph = new bool[][](nm[0], nm[0]);
    assert(graph.length == nm[0]);

    foreach (_; 0 .. nm[1])
    {
        auto tmp = aryread;
        graph[tmp[0] - 1][tmp[1] - 1] = true;
        graph[tmp[1] - 1][tmp[0] - 1] = true;
    }
    // writeln(graph);

    long[] list = iota(nm[0]).array();

    while (!list.empty)
    {
        long[] newlist;
        // writeln(graph);
        // writeln(list);
        foreach (i; list)
        {
            bool a = false;
            bool b = false;
            foreach (j; 0 .. nm[0])
            {
                a = a || (graph[i][j] && s[j] == 'A');
                b = b || (graph[i][j] && s[j] == 'B');
            }
            // writeln(i, a, b);
            if (a && b)
            {
                newlist ~= i;
            }
            else
            {
                foreach (j; 0 .. nm[0])
                {
                    graph[i][j] = false;
                    graph[j][i] = false;
                }
            }
        }
        if (list.length == newlist.length)
        {
            writeln("Yes");
            return;
        }
        list = newlist.dup;
    }
    writeln("No");
}
