(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const [n, m] = lines.shift().split(' ').map(Number);
  const adjLists = Array.from(Array(n), () => []);
  const d = [];

  let s, t;
  for (let i = 0; i < m; i++) {
    [s, t] = lines.shift().split(' ').map(Number);
    adjLists[s].push(t);
  }

  function canReach(s, t) {
    queue = [s];
    let u, v;
    while ((u = queue.shift()) !== undefined) {
      for (let i = 0; i < adjLists[u].length; i++) {
        v = adjLists[u][i];
        if (v === t) return true;
        queue.push(v);
      }
    }
    return false;
  }
  lines.shift();
  console.log(lines.map(l => canReach(...l.split(' ').map(Number)) ? 'yes' : 'no').join('\n'));
})();

