import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr, foldl', find)
import Data.Char (isSpace)
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import Control.Monad.State

main :: IO ()
main = do
  [n, m] <- readil B.readInt <$> B.getLine
  fs <- replicateM m (readil B.readInt <$> B.getLine)
  q <- readi B.readInt <$> B.getLine
  solve n fs <$> replicateM q (readil B.readInt <$> B.getLine) >>= mapM_ putStrLn

solve :: Int -> [[Int]] -> [[Int]] -> [String]
solve n fs qs = map f qs
  where gd = foldl' (\v [x, y] -> (v // [(x, y:(v ! x)), (y, x:(v ! y))])) (V.replicate n []) fs
        f [s, t] = evalState (dfs [s]) ((V.replicate n W) // [(s,B)])
          where dfs :: [Int] -> State (Vector Color) String
                dfs [] = return "no"
                dfs (u:st) = do
                  cd <- get
                  case find ((==W) . (cd !)) (gd ! u) of
                   Just v -> if v == t then return "yes"
                             else do
                               put $ cd // [(v,B)]
                               dfs (v:u:st)
                   Nothing -> dfs st

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
  where
    g s = do
      (n, s') <- f s
      return (n, B.dropWhile isSpace s')

data Color = W | B deriving (Show, Eq, Ord)

