### BUGGY CODE ###



n,m = map(int,input().split())
s = list(input())
edges = [tuple(map(int,input().split())) for i in range(m)]
abli = [[0,0] for i in range(n)]


def addEdge(graph,u,v):
    graph[u].add(v)


def deleteNode(graph,node):
    graph.pop(node,None)

from collections import defaultdict
graphAB = defaultdict(set)
graphABopp = defaultdict(set)

def incrementAB(node,adj):
    if s[adj-1] == 'A':
        abli[node-1][0]+=1
    if s[adj-1] == 'B':
        abli[node-1][1]+=1

def decrementAB(node,adj):
    if s[adj-1] == 'A':
        abli[node-1][0]-=1
    if s[adj-1] == 'B':
        abli[node-1][1]-=1

edgeset = set()
for i,j in edges:
    ii = min(i,j)
    jj = max(i,j)
    edgeset.add((ii,jj))

for i,j in edgeset:
    addEdge(graphAB,i,j)
    addEdge(graphABopp,j,i)
    incrementAB(i,j)
    if j!=i:
        incrementAB(j,i)


def adjAB(node):
    if abli[node-1][0]!=0 and abli[node-1][1]!=0:
        return(True)
    else:
        return(False)


#def adjAB(node):
#    Aflag = 'A' in map(lambda x:s[x-1],graphAB[node])
#    Aflag = Aflag or 'A' in map(lambda x:s[x-1],graphABopp[node])
#    Bflag = 'B' in map(lambda x:s[x-1],graphAB[node])
#    Bflag = Bflag or 'B' in map(lambda x:s[x-1],graphABopp[node])
#    if Aflag and Bflag:
#        return(True)
#    else:
#        return(False)



visitset = set([i for i in set(graphAB.keys())|set(graphABopp.keys()) if not adjAB(i)])
#print(visitset)

while bool(visitset):
    #print(graphAB)
    #print(graphABopp)
    #print(abli)
    i = visitset.pop()
    for j in graphAB[i]:
        graphABopp[j].remove(i)
        decrementAB(j,i)
        if not adjAB(j):
            visitset.add(j)
            #print(visitset,'add')
    for j in graphABopp[i]:
        graphAB[j].remove(i)
        decrementAB(j,i)
        if not adjAB(j):
            visitset.add(j)
            #print(visitset,'add')
    graphAB.pop(i,None)
    graphABopp.pop(i,None)

#print(graphAB)
#print(graphABopp)


if graphAB == {} and graphABopp == {}:
    print('No')
else:
    print('Yes')





### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
GC027 C
"""

n,m = map(int,input().split())
s = list(input())
edges = [tuple(map(int,input().split())) for i in range(m)]
ali = [0 for i in range(n)]
bli = [0 for i in range(n)]


def addEdge(graph,u,v):
    graph[u].add(v)


from collections import defaultdict
graphAB = defaultdict(set)

def incrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]+=1
    if s[adj-1] == 'B':
        bli[node-1]+=1

def decrementAB(node,adj):
    if s[adj-1] == 'A':
        ali[node-1]-=1
    if s[adj-1] == 'B':
        bli[node-1]-=1

for i,j in edges:
    addEdge(graphAB,i,j)
    addEdge(graphAB,j,i)

def adjAB(node):
    if ali[node-1]!=0 and bli[node-1]!=0:
        return(True)
    else:
        return(False)

graphvers = set(graphAB.keys())
visitset = set()
for i in range(1,n+1):
    if not i in graphvers:
        s[i-1] = 'C'
    else:
        for j in graphAB[i]:
            incrementAB(i,j)
        if not adjAB(i):
            visitset.add(i)


while bool(visitset):
    #print(graphAB)
    #print(graphABopp)
    #print(abli)
    i = visitset.pop()
    for j in graphAB[i]:
        if s[j-1] != 'C':
            decrementAB(j,i)
            if not adjAB(j):
                visitset.add(j)
    s[i-1] = 'C'

#print(graphAB)
#print(graphABopp)

sset= set(s)
sset.add('C')
sset.remove('C')
if bool(sset):
    print('Yes')
else:
    print('No')