parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,m = readline() |> split |> parseMap
	s = chomp(readline())
	g = [Int[] for i in 1:n]
	for i in 1:m
		a,b = readline() |> split |> parseMap
		push!(g[a],b)
		push!(g[b],a)
	end
	flg = 0
	chk = zeros(Int,n)
	for i in 1:n
		if chk[i] == 0
			as = Int[]
			bs = Int[]
			now = s[i]
			for j in 1:length(g[i])
				if chk[g[i][j]] == 0
					if s[g[i][j]] == 'A'
						push!(as,g[i][j])
					else
						push!(bs,g[i][j])
					end
				end
			end
			if isempty(as)||isempty(bs)
				chk[i] = 1
			else
				ccd = zeros(Int,n)
				for j in 1:length(as)
					lflg = 0
					for k in 1:length(g[as[j]])
						if s[g[as[j]][k]] != now
							lflg = 1
							ccd[g[as[j]][k]] = 1
						end
					end
					if lflg == 1
						chk[g[as[j]]] = 1
					end
				end
				for j in 1:length(bs)
					lflg = 0
					for k in length(g[bs[j]])
						if s[g[bs[j]][k]] != now
							lflg = 1
							if ccd[g[bs[j]][k]] == 1
								flg = 1
								break
							end
						end
					end
					if lflg == 1
						chk[g[bs[j]]] = 1
					end
				end
			end
		end
	end
	println(flg==1?"Yes":"No")
end
main()