### BUGGY CODE ###

#####segfunc#####
def segfunc(x, y):
    return min(x,y)
#################

#####ide_ele#####
ide_ele = [float("inf"),-1]
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k][0] += x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

import sys

input=sys.stdin.readline

N,M=map(int,input().split())
s=input()
A=[[0,i] for i in range(N)]
B=[[0,i] for i in range(N)]
edge=[[] for i in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    a-=1;b-=1
    edge[a].append(b)
    edge[b].append(a)
    A[b][0]+=(s[a]=="A")
    B[b][0]+=(s[a]=="B")
    A[a][0]+=(s[b]=="A")
    B[a][0]+=(s[b]=="B")

Acheck=SegTree(A,segfunc,ide_ele)
Bcheck=SegTree(B,segfunc,ide_ele)

ban=set([])
while True:
    a,index=Acheck.query(0,N)
    b,index2=Bcheck.query(0,N)
    if a==0:
        ban.add(index)
        Acheck.update(index,float("inf"))
        Bcheck.update(index,float("inf"))
        if s[index]=="A":
            for v in edge[index]:
                Acheck.update(v,-1)
        else:
            for v in edge[index]:
                Bcheck.update(v,-1)
    elif b==0:
        ban.add(index2)
        Acheck.update(index2,float("inf"))
        Bcheck.update(index2,float("inf"))
        if s[index2]=="A":
            for v in edge[index2]:
                Acheck.update(v,-1)
        else:
            for v in edge[index2]:
                Bcheck.update(v,-1)
    else:
        break

check=set([i for i in range(N)])
if ban==check:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

import sys

input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    s=input()
    dic={"A":[0 for i in range(N)],"B":[0 for i in range(N)]}
    edge=[[] for i in range(N)]

    for i in range(M):
        a,b=map(int,input().split())
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)
        dic[s[a]][b]+=1
        dic[s[b]][a]+=1

    que=set([])
    check=0
    for i in range(N):
        if dic["A"][i]==0 or dic["B"][i]==0:
            que.add(i)


    while que:
        v=que.pop()
        check+=v+1
        dic["A"][v]=float("inf")
        dic["B"][v]=float("inf")
        for nv in edge[v]:
            dic[s[v]][nv]-=1
            if dic["A"][nv]==0 or dic["B"][nv]==0:
                que.add(nv)

    if check==N*(N+1)//2:
        print("No")
    else:
        print("Yes")

if __name__=="__main__":
    main()