//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline)
  .map(function (line) { return line.split(' ').map(Number); });

n = line[0][0];
m = line[0][1];
q = line[m+1][0];

adj = new Array(n);
for (i = 0; i < n; i++) adj[i] = [[i]];

for (i = 1; i <= m; i++) {
  if (adj[line[i][0]] === adj[line[i][1]]) continue;
  if (adj[line[i][0]][0].length <= adj[line[i][1]][0].length) {
    min = adj[line[i][0]];
    max = adj[line[i][1]];
  } else {
    min = adj[line[i][1]];
    max = adj[line[i][0]];
  }
  max[0] = max[0].concat(min[0]);
  for (j in min[0]) adj[min[0][j]] = max;
}

for (i = m+2; i < (m+2) + q; i++)
  console.log((adj[line[i][0]] === adj[line[i][1]]) ? 'yes' : 'no');