let () = Scanf.scanf "%d %d\n%s\n" @@ fun n m s ->
  let es = Array.make n [] in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      es.(a - 1) <- b - 1 :: es.(a - 1);
      es.(b - 1) <- a - 1 :: es.(b - 1)
  done;
  let dp = Array.make n None in
  let rec solve v =
    match dp.(v) with
    | Some b -> b
    | None ->
        dp.(v) <- Some true;
        let b = solve_seq es.(v) in
        dp.(v) <- Some b; b
  and solve_seq vs =
    let a, b = List.fold_left (fun (a, b) u ->
      if s.[u] = 'A'
      then (a || solve u, b)
      else (a, b || solve u)) (false, false) vs in
    a && b in
  print_endline @@
    if
      solve_seq @@
      Array.to_list @@
      Array.init n @@
      fun v -> v
    then "Yes"
    else "No"
