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]);
		auto n2      = to!int(tokens2[1]);
		node[n1] ~= n2;
		node[n2] ~= n1;
	}

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

	int changed = int.max;
	while (changed != 0)
	{
		changed = 0;
		foreach (i, node2; node)
		{
			if (!nodeS[i]) continue;

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

				char c2 = s[j];
				if (c1 == c2) isDone1 = true;
				else		  isDone2 = true;
			}
			if (!isDone1 || !isDone2)
			{
				nodeS[i] = false;
				++changed;
			}
		}
	}

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

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