//const int N = 2e5+5;
//string s;
//vector<int> adj[N];
//ll cnt[N][2];
//string _(){
//    int n,m;
//    cin >> n >> m;
//    cin >> s;
//    for(int i = 0; i < n; ++i)
//        s[i] = s[i]-'A';
//    for(int i = 0; i < m; ++i){
//        int a,b;
//        cin >> a >> b;
//        --a;
//        --b;
//        adj[a].pb(b);
//        adj[b].pb(a);
//        cnt[a][s[b]]++;
//        cnt[b][s[a]]++;
//    }
//    vector<bool> visited(n);
//    vector<int> bfs;
//    for(int i = 0; i < n; ++i)
//        if(cnt[i][0]*cnt[i][1] == 0){
//            visited[i] = true;
//            bfs.pb(i);
//        }
//    for(int i = 0; i < bfs.size(); ++i){
//        int u = bfs[i];
//        for(int v : adj[u]){
//            cnt[v][s[u]]--;
//            if(!visited[v] && cnt[v][0]*cnt[v][1] == 0){
//                visited[v] = true;
//                bfs.pb(v);
//            }
//        }
//    }
//    if(bfs.size() == n)
//        return "No";
//    return "Yes";
//}
//
//
// ================================================ 
// ^^^	ABOVE is what I wrote in my editor	^^^
// ------------------------------------------------ 
// vvv	BELOW is automatically generated 	vvv
// ================================================ 
#include <set>
#include <iomanip>
#include <cassert>
#include <vector>
#include <iostream>
#define pb push_back 
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long ll;
template<typename IT>
ostream &print(IT b, IT e, string sep = " ", ostream &stream = cout){
	for(IT it = b; it != e; ++it){
		stream << *it;
		if(it+1 != e) stream << sep;
	} 
	return stream;
}
template<typename IT> istream &read(IT b, IT e, istream &stream = cin){
	for(IT it = b; it != e; ++it) stream >> *it; return stream;
}
template<typename T> ostream &operator<<(ostream &stream, vector<T> &t){
	return print(all(t)," ",stream);
}
template<typename T> ostream &operator<<(ostream &stream, vector<T> &&t){
	return print(all(t)," ",stream);
}
template<typename T> istream &operator>>(istream &stream, vector<T> &t){
	return read(all(t),stream);
}
template <typename T> 
void print(T x){
	cout << x << '\n';
}
template <typename t> 
void print(vector<t> arr,string sep=" "){
    if(arr.empty())
        return;
	print(arr.begin(),arr.end(),sep);
	cout << '\n';
}
template <typename T> 
void print(vector<vector<T> > arr){
	for(int i = 0; i < arr.size(); ++i){
		cout << "[" << arr[i] << "]";
		if(i+1 < arr.size())
			cout << ", ";
	}
	cout << '\n';
}
template<typename T>
T _();
const ll INF = ll(2e18)+666;
const ll MOD = 1e9+7;
template<typename T>
vector<T> operator+(const vector<T> &lhs, const vector<T> &rhs){
	vector<T> ans(lhs);
	assert(ans.size() == rhs.size());
	for(int i = 0; i < rhs.size(); ++i)
		ans[i] += rhs[i];
	return ans;
}
template<typename T>
vector<T> operator+=(vector<T> &lhs, const vector<T> &rhs){
	return lhs = lhs+rhs;
	//vector<T> ans(lhs);
	//assert(ans.size() == rhs.size());
	//for(int i = 0; i < rhs.size(); ++i)
		//ans[i] += rhs[i];
	//return ans;
}
template<typename T>
vector<T> operator-(const vector<T> &lhs, const vector<T> &rhs){
	vector<T> ans(all(lhs));
	assert(ans.size() == rhs.size());
	for(int i = 0; i < rhs.size(); ++i)
		ans[i] -= rhs[i];
	return ans;
}
template<typename T>
vector<T> operator-=(vector<T> &lhs, const vector<T> &rhs){
	return lhs = lhs-rhs;
	//vector<T> ans(lhs);
	//assert(ans.size() == rhs.size());
	//for(int i = 0; i < rhs.size(); ++i)
		//ans[i] += rhs[i];
	//return ans;
}
template<typename T>
T max(const vector<T> arr){
	assert(!arr.empty());
	T ans = arr[0];
	for(auto &cur : arr)
		ans = max(ans,cur);
	return ans;
}
template<typename T>
T max(const set<T> s){
	assert(!s.empty());
	return *--s.end();
}
template<typename T, typename G>
vector<T> set_max(vector<T> &base, const vector<G> &comp){
	assert(base.size() == comp.size());
	for(int i = 0; i < (int)comp.size(); ++i)
		base[i] = max(base[i],comp[i]);
	return base;
}
const int N = 2e5+5;
string s;
vector<int> adj[N];
ll cnt[N][2];
string _(){
    int n,m;
    cin >> n >> m;
    cin >> s;
    for(int i = 0; i < n; ++i)
        s[i] = s[i]-'A';
    for(int i = 0; i < m; ++i){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        adj[a].pb(b);
        adj[b].pb(a);
        cnt[a][s[b]]++;
        cnt[b][s[a]]++;
    }
    vector<bool> visited(n);
    vector<int> bfs;
    for(int i = 0; i < n; ++i)
        if(cnt[i][0]*cnt[i][1] == 0){
            visited[i] = true;
            bfs.pb(i);
        }
    for(int i = 0; i < bfs.size(); ++i){
        int u = bfs[i];
        for(int v : adj[u]){
            cnt[v][s[u]]--;
            if(!visited[v] && cnt[v][0]*cnt[v][1] == 0){
                visited[v] = true;
                bfs.pb(v);
            }
        }
    }
    if(bfs.size() == n)
        return "No";
    return "Yes";
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(12);
	cout << _() << '\n';
}


Measured memory_bytes: 14796