{-# LANGUAGE FlexibleContexts #-}

module Main where

import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
-- import Data.Array.IO
import Data.Maybe
import qualified Data.Map as M
-- import Control.Monad.ST
-- import Data.STRef
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf
    
solve :: Int -> [[Int]] -> [[Int]] -> [Bool]
solve n al ql = map (\[x, y] -> components M.! x == components M.! y) ql where  
    components = iter 1 usedVertices [0..n-1] where
        iter c tbl [] = tbl 
        iter c tbl (x:xs) 
            | M.member x tbl = iter c tbl xs
            | otherwise = iter (c+1) (dfs tbl x) xs where
                dfs tbl x
                    | M.notMember x tbl = foldl' dfs updateTbl (adjacentsList!x)
                    | otherwise = tbl where
                        updateTbl = M.insert x c tbl

    usedVertices = M.empty            
    adjacentsList = accumArray (flip (:)) [] (0, n-1) $ [(x,y) | [x,y] <- al]++[(y,x) | [x,y] <- al]

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

print' :: Bool -> IO ()
print' True  = putStrLn "yes" 
print' False = putStrLn "no" 

main :: IO() 
main = do
    [n, m] <- readIntList
    al <- replicateM m readIntList
    q  <- readIntLn
    ql <- replicateM q readIntList
    mapM_ print' $ solve n al ql

