subtask1全WA了
#include<iostream>
#include<random>
#include<ctime>
using namespace std;
template<typename T>inline void read(T &x){
x=0;T f=1;char ch=getchar();
while(ch<48&&ch>57){if(ch=='-'){f=-1;}ch=getchar();}
while(ch>=48&&ch<=57){x=x*10+ch-48;ch=getchar();}
x*=f;
}
template<typename T>inline void write(T x){
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10-48);
}
const int N=5e5+8;
int n,m,q;
mt19937_64 g(time(0));
unsigned long long w[N];
unsigned long long in[N];
unsigned long long bucin[N];
unsigned long long tot=0;
int main(){
// freopen("galaxy.in","r",stdin);
// freopen("galaxy.out","w",stdout);
read(n),read(m);
unsigned long long real=0;
for(int i=1;i<=n;i++){
w[i]=g();
real+=w[i];
}
for(int i=1;i<=m;i++){
int u,v;
read(u),read(v);
in[v]+=w[u];
bucin[v]+=w[u];
tot+=w[u];
}
read(q);
int t,u,v;
while(q--){
read(t);
if(t==1){
read(u),read(v);
in[v]-=w[u];
tot-=w[u];
}
else if(t==2){
read(u);
tot-=in[u];
in[u]=0;
}
else if(t==3){
read(u),read(v);
in[v]+=w[u];
tot+=w[u];
}
else{
read(u);
tot+=bucin[u]-in[u];
in[u]=bucin[u];
}
if(real==tot){
puts("YES");
}
else{
puts("NO");
}
}
return 0;
}