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[][] node;
	node.length = n;
	foreach (i; 0..m)
	{
		auto tokens2 = split(chomp(readln()));
		auto n1      = to!int(tokens2[0]) - 1;
		auto n2      = to!int(tokens2[1]) - 1;
		node[n1] ~= n2;
		node[n2] ~= n1;
	}

	bool[] nodeS;
	nodeS.length = n;
	fill(nodeS, true);

	void compute(int i)
	{
		bool isDone1 = false, isDone2 = false;
		char c1 = s[i];
		foreach (j; node[i])
		{
			if (!nodeS[j]) continue;

			char c2 = s[j];
			if (c1 == c2) isDone1 = true;
			else		  isDone2 = true;
		}
		if (!isDone1 || !isDone2)
		{
			nodeS[i] = false;
			foreach (j; node[i])
			{
				if (!nodeS[j]) continue;
				compute(j);
			}
		}
	}

	foreach (i, node2; node)
	{
		compute(cast(int)i);
	}

	bool isComplete = false;
	foreach (e; nodeS) if (e) isComplete = true;

	writeln(isComplete ? "Yes" : "No");
	stdout.flush();
}