/*
Stranger than the comet as it streaks across the sky
Stranger than the truth I know before my open eyes
I have dealt in mysteries and trickery, of light to entertain
Looked into the abyss, called it by its name

I have plundered time itself, put the world inside it
And the mysteries, day and night, divide it
A plague of wonders, on your knees beside me
Know the secrets, you shall not deride us

My dreams of empire for my frozen queen
Will come to pass
Know me, the Magus
I am Dr. Dee
And this is my house

I am the master of the tides
I shame the mirror in my sight
What random music of the spheres across the years

Know this I will return to this land
Rebuild where the ruins did stand
Chain of the demons set free
Strange alchemy

Gather round the aimless and the feckless and the lame
Hear the master summon up the spirits by their names
I curse you Edward Kelly your betrayal for eternity is damned
Know you speak with demons you cannot command

Even as I looked into the glass then I was blinded
Burning by the Mortlake shore my house my books inside it
You have taken up my wife and lain beside her
Now the black rain on my house, the timbers burning

My dreams of empire for my frozen queen
Will come to pass
Know me, the Magus
I am Dr. Dee
And this was my house

I was the keeper of the books
I had the knowledge of the scrolls
But now through ignorance and fear
I cast a shadow through the years

Know this I will return to this land
Rebuild where the ruins did stand
Chain of the demons set free
Strange alchemy

Know this
I will return to this land
Rebuild where the ruins did stand
Chain of the demons set free
Strange alchemy

Know this
I will return to this land
Rebuild where the ruins did stand
Restore the knowledge memory
Strange alchemy
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600000;

int n,m;
string st;
int tp[N];
int a[N],b[N];
vector<int> edges[N];
vector<int> leaves;
int cnt[N][4];
int dead[N];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n>>m;

	cin>>st;
	for (int i=0;i<st.size();i++){
		if (st[i]=='A')
			tp[i+1]=1;
		else
			tp[i+1]=2;
	}

	for (int i=1;i<=m;i++){
		cin>>a[i]>>b[i];
		edges[a[i]].push_back(i);
		if (b[i]!=a[i])
			edges[b[i]].push_back(i);
	}

	for (int i=1;i<=n;i++){
		for (int j=0;j<edges[i].size();j++){
			int id=edges[i][j];
			int to=a[id]+b[id]-i;
			cnt[i][tp[to]]++;
		}
	}

	for (int i=1;i<=n;i++){
		if (cnt[i][1]==0||cnt[i][2]==0){
			leaves.push_back(i);
			dead[i]=1;
		}
	}

	while (leaves.size()){
		int v=leaves.back();
		leaves.pop_back();
		for (int i=0;i<edges[v].size();i++){
			int id=edges[v][i];
			int to=a[id]+b[id]-v;
			if (dead[to])
				continue;
			cnt[to][tp[v]]--;
			if (cnt[to][1]==0||cnt[to][2]==0)
			{
				dead[to]=1;
				leaves.push_back(to);
			}
		}
	}

	for (int i=1;i<=n;i++){
		if (dead[i]==0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 33740