#include<bits/stdc++.h>
using namespace std;
int q, t, n, m, u, v, w;
int main()
{
freopen("csp2022_galaxy.in","r",stdin);
freopen("csp2022_galaxy.out","w",stdout);
cin >> n>> m;
for(int i = 1; i <= m; i++)
cin >> u >> v;
cin >> q;
for(int i = 1; i<= q; i++)
{
cin >> t;
if(t == 1|| t== 3)
cin >> u >> w >> w;
else
cin >> u >> v;
}
for(int i = 1; i <= q; i++)
cout <<"NO" << endl;
return 0;
}