#include <bits/stdc++.h>
using namespace std;
const int N=10+5;
int n,m,q;
bool mp[N][N],b[N][N];
int tot=0;
bool dfs(int pt){
int cnt=0;tot++;
if (tot>n)return 1;
for (int i=1;i<=n;i++){
cnt+=mp[pt][i];
}
if (!cnt||cnt>1)return 0;
for (int i=1;i<=n;i++){
if (mp[pt][i])return dfs(i);
}
}
bool chck(){
bool yes=1;
for (int i=1;i<=n;i++){
tot=0;
yes&=dfs(i);
}
return yes;
}
int main(){
freopen ("csp2022_galaxy.in","r",stdin);
freopen ("csp2022_galaxy.out","w",stdout);
scanf("%d%d",&n,&m);
for (int i=1;i<=m;i++){
int x,y;scanf("%d%d",&x,&y);
mp[x][y]=b[x][y]=1;
}
scanf("%d",&q);
while(q--){
int opt,x,y;scanf("%d%d",&opt,&x);
if (opt==1){
scanf("%d",&y);
mp[x][y]=0;
}
if (opt==2){
for (int i=1;i<=n;i++)mp[i][x]=0;
}
if (opt==3){
scanf("%d",&y);
mp[x][y]=1;
}
if (opt==4){
for (int i=1;i<=n;i++)mp[i][x]=b[i][x];
}
if (chck())printf("YES\n");
else printf("NO\n");
}
return 0;
}