import scala.collection.mutable
import scala.io.StdIn._

object Main extends App {
  val Array(n, m) = readLine().split(" ").map(_.toInt)
  var queue: mutable.Queue[Set[Int]] = mutable.Queue(Set())

  for (i <- 1 to m) {
    val Array(v1, v2) = readLine().split(" ").map(_.toInt)
    var set: Set[Int] = Set(v1, v2)

    while (queue.front.nonEmpty) {
      if (queue.front.contains(v1) || queue.front.contains(v2))
        set ++= queue.dequeue()
      else queue.enqueue(queue.dequeue())
    }

    queue.enqueue(set)
    queue.enqueue(queue.dequeue())
  }

  for (i <- 1 to readInt()) {
    val Array(v1, v2) = readLine().split(" ").map(_.toInt)
    if (queue exists (s => s.contains(v1) && s.contains(v2)))
      println("yes")
    else println("no")
  }
}