object Main extends App {
  val Array(n, m) = io.StdIn.readLine().split(" ").map(_.toInt)
  val adjacents: Array[Array[Boolean]] = Array.fill(n)(Array.fill(n)(false))
  for (_ <- 0 until m) {
    val Array(s, t) = io.StdIn.readLine().split(" ").map(_.toInt)
    adjacents(s)(t) = true
  }
  val q: Int = io.StdIn.readInt()
  for (_ <- 0 until q) {
    val Array(s, t) = io.StdIn.readLine().split(" ").map(_.toInt)
    println(if (adjacents(s)(t) || adjacents(t)(s)) "yes" else "no")
  }
}
