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

case class Edge(from: Int, to: Int)

object Main extends App {
  val Array(n, m) = readLine().split(" ").map(_.toInt)
  val reached: mutable.Seq[Set[Int]] = mutable.Seq.fill(n)(Set())
  var edges: Set[Edge] = Set()

  for (i <- 1 to m) {
    val Array(from, to) = readLine().split(" ").map(_.toInt)
    reached(from) += to
    reached(to) += from
    edges += Edge(from, to)
    edges += Edge(to, from)
  }

  for (i <- 1 to readInt()) {
    val Array(f, t) = readLine().split(" ").map(_.toInt)
    if (canReach(f, t)) println("yes") else println("no")
  }

  def canReach(from: Int, to: Int): Boolean = {
    if (reached(from) contains to) return true

    var searched: Set[Edge] = Set()
    val queue: mutable.Queue[Edge] = mutable.Queue()

    edges.collectFirst {
      case e@Edge(f, _) if f == from => queue.enqueue(e)
    }

    while (queue.nonEmpty) {
      val edge = queue.dequeue()
      searched += edge

      if (reached(edge.from) contains to) {
        reached(from) += to
        return true
      }

      edges.foreach(e => {
        if (!searched.contains(e) && (e.from == edge.from || e.from == edge.to)) {
          reached(from) += e.to
          reached(e.to) += from
          reached(edge.from) += e.to
          reached(e.to) += edge.from
          if (e.to == to) return true
          queue.enqueue(e)
        }
      })
    }

    false
  }
}