#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

struct info {
	int to, rev, flg;
};

int main() {
	int N, M; cin >> N >> M;
	string s; cin >> s;
	
	vector<vector<info>> edge(N);
	REP(i,M){
		int a, b; cin >> a >> b;
		a--; b--;
		edge[a].push_back({ b,(int)edge[b].size(),1});
		edge[b].push_back({ a,(int)edge[a].size() - 1,1 });
	}

	V<P<int, int>> ord(N);
	REP(i, N) ord[i] = { 0,i };

	queue<int> q;
	REP(i,N) {
		if (ord[i].first == 0) {
			q.push(i);
			ord[i].first = 1;
		}
		while(q.size()){
			int from = q.front();
			q.pop();
			for(auto u: edge[from]){
				if (ord[u.to].first) continue;
				ord[u.to].first = ord[from].first + 1;
				q.push(u.to);
			}
		}
	}
	sort(ALL(ord));
	
	V<int> node(N, 1);
	REP(n, 100) {
		REP(i, N) {
			if (!node[ord[i].second]) continue;
			int flgA = 0, flgB = 0;
			for (auto u : edge[ord[i].second]) {
				if (u.flg && s[u.to] == 'A') flgA = 1;
				if (u.flg && s[u.to] == 'B') flgB = 1;
			}
			if (flgA && flgB) continue;
			node[ord[i].second] = 0;
			for (auto u : edge[ord[i].second]) {
				u.flg = 0;
				edge[u.to][u.rev].flg = 0;
			}
		}
		REP(i, N) {
			if (!node[ord[N - 1 - i].second]) continue;
			int flgA = 0, flgB = 0;
			for (auto u : edge[ord[N - 1 - i].second]) {
				if (u.flg && s[u.to] == 'A') flgA = 1;
				if (u.flg && s[u.to] == 'B') flgB = 1;
			}
			if (flgA && flgB) continue;
			node[ord[N - 1 - i].second] = 0;
			for (auto u : edge[ord[N - 1 - i].second]) {
				u.flg = 0;
				edge[u.to][u.rev].flg = 0;
			}
		}
	}
	Yn(accumulate(ALL(node), 0)>1);

	return 0;
}



Measured memory_bytes: 14980