N, M = gets.split.map &:to_i
group_parents = []
group = []
M.times{
  s, t = gets.split.map &:to_i
  if group_parents.include? s
    group[s] ||= []
    group[s] << t unless group[s].include? t
  elsif group_parents.include? t
    group[t] ||= []
    group[t] << s unless group[t].include? s
  else
    include_flag = false
    group_parents.each{|i|
      if group[i].include? s
        group[i] << t unless group[i].include? t
        include_flag = true
        break
      elsif group[i].include? t
        group[i] << s unless group[i].include? s
        include_flag = true
        break
      end
    }
    unless include_flag
      group_parents << s
      group[s] = [t]
    end
  end
}
gets.to_i.times{
  s, t = gets.split.map &:to_i
  if group_parents.include?(s) && group[s].include?(t)
    puts :yes
  elsif group_parents.include?(t) && group[t].include?(s)
    puts :yes
  else
    friend_flag = false
    group_parents.each{|i|
      if group[i].include?(s) && group[i].include?(t)
        puts :yes
        friend_flag = true
        break
      end
    }
    puts :no unless friend_flag
  end
}