import std.stdio;
import std.algorithm;
import std.conv;
import std.string;

void main()
{
	auto tokens = split(chomp(readln()));
	auto n   = to!int(tokens[0]);
	auto m   = to!int(tokens[1]);
	string s = chomp(readln());
	int[2][] edge;
	int[][] node;
	node.length = n;
	foreach (i; 0..m)
	{
		auto tokens2 = split(chomp(readln()));
		auto n1      = to!int(tokens2[0]);
		auto n2      = to!int(tokens2[1]);
		node[n1] ~= n2;
		node[n2] ~= n1;
	}

	bool isDoneA = false, isDoneB = false;
	foreach (i, node2; node)
	{
		bool isDone1 = false, isDone2 = false;
		char c1 = s[i];
		foreach (j; node2)
		{
			char c2 = s[j];
			if (c1 == c2) isDone1 = true;
			else		  isDone2 = true;
		}
		if (isDone1 && isDone2)
		{
			if (c1 == 'A')
				isDoneA = true;
			else
				isDoneB = true;
		}
	}

	writeln(isDoneA && isDoneB ? "Yes" : "No");
	stdout.flush();
}