#include<bits/stdc++.h>
bool g[5000][5000];
int main()
{
int n, m, u, v;
while(~scanf("%d%d", &n, &m))
{
memset(g,0,sizeof(g));
for(int i=0; i<m; i++)
{
scanf("%d%d", &u, &v);
g[u][v]=1;
}
int q;
scanf("%d", &q);
while(q--)
{
int a, b;
scanf("%d%d", &a, &b);
if(g[a][b])
{
printf("Yes\n");
}
else
{
printf("No\n");
}
}
}
return 0;
}
/***************************************************
User name: ACM18171信科1801张林
Result: Accepted
Take time: 1300ms
Take Memory: 2164KB
Submit time: 2019-01-01 17:39:45
****************************************************/