#include<iostream>
#include<stdio.h>
#include<functional>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<cstring>
#include<string>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define lli long long int
#define mod1 1000000007
#define mod2 1000000009
#define ppi pair<int,int>
#define tr(a,it) for(typeof(a.begin()) it=a.begin();it!=a.end();it++)
#define N 100001
using namespace std;
vector<int>v[N];
map< ppi ,int >ce;
int mark[N]={0};
int d[N],h[N];
int markv[N]={0};
int dp[N][20];
int dfs(int s)
{
if(mark[s]!=0)return 0;
mark[s]=1;
d[s]=h[s];
int pow=2;
FOR(i,1,20)
{
if(h[s]-pow<1)break;
dp[s][i]=dp[dp[s][i-1]][i-1];
pow*=2;
}
FOR(i,0,v[s].size()-1)
{
if(mark[v[s][i]]==0)
{
dp[v[s][i]][0]=s;//lca intial
h[v[s][i]]=h[s]+1;
dfs(v[s][i]);
d[s]=min(d[s],d[v[s][i]]);
if(d[v[s][i]]>h[s])
{
ce[ppi(s,v[s][i])]=1;
ce[ppi(v[s][i],s)]=1;
}
else
{
ce[ppi(s,v[s][i])]=0;
ce[ppi(v[s][i],s)]=0;
}
}
else
{
if(dp[s][0]!=v[s][i])
{
d[s]=min(d[s],d[v[s][i]]);
}
}
}
if(d[s]>=h[s])
{
markv[s]=1;
}
return 0;
}
int sh(int a,int b)
{
if(h[b]<h[a])swap(a,b);
if(h[a]==h[b])return b;
int k=0,pow=1;
while(h[b]-pow>=h[a])
{
pow*=2;
k++;
}
k--;
FORD(i,k,0)
{
if(h[dp[b][i]]>=h[a])
{
b=dp[b][i];
}
}
return b;
}
int lca(int a,int b)
{
if(h[a]>h[b])swap(a,b);
b=sh(a,b);
if(a==b)return a;
int k=0,pow=1;
while(h[b]-pow>0)
{pow*=2;
k++;
}
k--;
FORD(i,k,0)
{
if(dp[a][k]!=dp[b][k])
{
a=dp[a][k];
b=dp[b][k];
}
}
return dp[a][0];
}
int q1(int a,int b,int x,int y)
{
if(ce[ppi(x,y)]==0)return 1;
if(h[x]<h[y])swap(x,y);
int s1=-1,s2=-1;
if(lca(x,a)==x)s1=1;
if(lca(x,b)==x)s2=1;
if(s1*s2==1)return 1;
else
return 0;
}
int q2(int a,int b,int c)
{
if(markv[c]==0)return 1;
if(lca(a,c)==c&&lca(b,c)==lca(a,b))return 0;
else
if(lca(b,c)==c&&lca(a,c)==lca(a,b))return 0;
return 1;
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
FOR(i,0,m-1)
{
int x,y;
scanf("%d%d",&x,&y);
v[x].pb(y);
v[y].pb(x);
}
dp[1][0]=0;
h[1]=1;
dfs(1);
int q;
scanf("%d",&q);
//cout<<endl<<d[2]<<endl<<markv[2]<<endl;
while(q--)
{
int t;
scanf("%d",&t);
int a,b;
scanf("%d%d",&a,&b);
if(t==1)
{
int x,y;
scanf("%d%d",&x,&y);
//cout<<endl<<ce[ppi(x,y)]<<endl;
if(q1(a,b,x,y))
{
printf("da\n");
}
else
{printf("ne\n");
}
}
else
{
int c;
scanf("%d",&c);
if(q2(a,b,c))
{
printf("da\n");
}
else
{printf("ne\n");
}
}
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0ZGlvLmg+CiNpbmNsdWRlPGZ1bmN0aW9uYWw+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8bWF0aC5oPgojaW5jbHVkZTxsaW1pdHMuaD4KCiNpbmNsdWRlPHNldD4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxtYXA+CiNpbmNsdWRlPHF1ZXVlPgojaW5jbHVkZTxzdGFjaz4KI2luY2x1ZGU8ZGVxdWU+CgojaW5jbHVkZTxjc3RyaW5nPgojaW5jbHVkZTxzdHJpbmc+CgoKI2RlZmluZSBGT1IoaSxhLGIpIGZvcihpbnQgaT1hO2k8PWI7aSsrKQojZ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