import scala.io.StdIn.{readLine, readInt};
object Main {
    def main(args: Array[String]): Unit = {
        val input = readLine.split(" ").map(_.toInt);
        val g = new AdjacentListGraph[Int]();
        (0 until input(1)).foreach { i =>
            readLine.split(" ").map(_.toInt) match {
                case Array(src, dst) => g.add(src, dst);
                case _ => ();
            }
        }
        val f = (a: Int, b: Int) => a == b;
        (0 until readInt).foreach { i =>
            readLine.split(" ").map(_.toInt) match {
                case Array(src, dst) => if (g.connectedTo(src, dst)(f)) println("yes") else println("no");
                case _ => ()
            }
        }
        
    }
}
class AdjacentListGraph[A] {
    val al = scala.collection.mutable.HashMap[A, List[A]]();
    var size = 0;

    def dump = al.toList.foreach { e => println("%d -> %s".format(e._1, e._2.mkString(" ")))}

    def add(elem: A, dst: A): Unit = {
        al.put(elem, dst :: al.getOrElse(elem, Nil));
        size += 1;
    }

    def connectedTo(src: A, dst: A)(eq: (A, A) => Boolean): Boolean = {
        val vMap = scala.collection.mutable.HashMap[A, Int]();
        def dfs(curr: A): Boolean = if (eq(curr, dst)) { true } else {
            for (e <- al.getOrElse(curr, Nil)) {
                if (!vMap.isDefinedAt(e)) {
                    vMap.put(e, 1);
                    if (dfs(e)) return true;
                }
            }
            false;
        }
        dfs(src);
    }
}
