#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 c=1;
int timer=1;
int first[N],last[N];
int dp[N][20];
int dfs(int s)
{
if(mark[s]!=0)return 0;
mark[s]=c;
first[s]=timer;
timer++;
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;
}
last[s]=timer;
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(mark[a]!=mark[b])return 0;
if(ce[ppi(x,y)]==0)return 1;
if(h[x]<h[y])swap(x,y);
int s1=-1,s2=-1;
if(first[x]<=first[a]&&first[a]<=last[x])s1=1;
if(first[x]<=first[b]&&first[b]<=last[x])s2=1;
if(s1*s2==1)return 1;
else
return 0;
}
int q2(int a,int b,int c)
{
if(mark[a]!=mark[b])return 0;
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);
}
FOR(i,1,n)
{
if(mark[i]==0)
{
dp[i][0]=0;
h[i]=1;
dfs(i);
c++;
}
}
//cout<<ce[ppi(1,2)]<<endl;
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
{
scanf("%d",&c);
if(q2(a,b,c))
{
printf("da\n");
}
else
{printf("ne\n");
}
}
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0ZGlvLmg+CiNpbmNsdWRlPGZ1bmN0aW9uYWw+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8bWF0aC5oPgojaW5jbHVkZTxsaW1pdHMuaD4KCiNpbmNsdWRlPHNldD4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxtYXA+CiNpbmNs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