local n, m = io.read("*n", "*n", "*l")
local s = io.read()
local v = {}
local edge = {}
local acnt, bcnt = {}, {}
for i = 1, n do
  v[i] = s:byte(i) - 64
  edge[i] = {}
  acnt[i], bcnt[i] = 0, 0
end
for i = 1, m do
  local a, b = io.read("*n", "*n")
  table.insert(edge[a], b)
  table.insert(edge[b], a)
  if v[a] == 1 then
    acnt[b] = acnt[b] + 1
  else
    bcnt[b] = bcnt[b] + 1
  end
  if v[b] == 1 then
    acnt[a] = acnt[a] + 1
  else
    bcnt[a] = bcnt[a] + 1
  end
end
local tasks = {}
for i = 1, n do
  if acnt[i] * bcnt[i] == 0 then
    table.insert(tasks, i)
  end
end
local done = 0
while done < #tasks do
  done = done + 1
  local src = tasks[done]
  local cnttbl = v[src] == 1 and acnt or bcnt
  for j = 1, #edge[src] do
    local dst = edge[src][j]
    if 0 < acnt[dst] and 0 < bcnt[dst] then
      cnttbl[dst] = cnttbl[dst] - 1
      if cnttbl[dst] == 0 then
        table.insert(tasks, dst)
      end
    end
  end
end
print(#tasks == n and "No" or "Yes")
