import java.util.*

// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}

fun main(args: Array<String>) {
  val (n, m) = fastReadInts(2)
  val label = readLine()!!
  val graph = Array(n, { mutableListOf<Int>() })
  repeat(m) {
    val (v1Input, v2Input) = fastReadInts(2)
    val v1 = v1Input - 1
    val v2 = v2Input - 1
    if (v1 != v2) {
      graph[v1].add(v2)
      graph[v2].add(v1)
    } else {
      graph[v1].add(v1)
    }
  }

  val aCount = IntArray(n)
  val bCount = IntArray(n)
  for (v in 0 until n) {
    for (u in graph[v]) {
      if (label[u] == 'A') {
        aCount[v]++
      } else {
        bCount[v]++
      }
    }
  }

  val q = Stack<Int>()
  for (v in 0 until n) {
    q.push(v)
  }

  val isBad = BooleanArray(n)
  while (q.isNotEmpty()) {
    val v = q.pop()
    if (isBad[v]) continue
    if (aCount[v] == 0 || bCount[v] == 0) {
      isBad[v] = true
      for (u in graph[v]) {
        if (u != v && !isBad[u]) {
          q.push(u)
          if (label[v] == 'A') {
            aCount[u]--
          } else {
            bCount[u]--
          }
        }
      }
    }
  }

  if (isBad.all { it }) {
    println("No")
  } else {
    println("Yes")
  }
}
