#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define EPS 1e-9


double AB(int tx,int ty,int sx,int sy){
    double x = tx-sx;
    double y = ty-sy;
    return sqrt( (x*x)+(y*y) );
}


double inner(int ax,int ay,int bx,int by){
	return ax*bx + ay*by;
}

bool isCross(int wx,int wy,int r,  int tx,int ty,int sx,int sy){
	//	cout<<tx<<" "<<sx<<" "<<wy<<" "<<ty<<" "<<sy<<" "<<wx<<endl;
	double vc = inner( tx-sx,ty-sy,wx-sx,wy-sy );
//	cout<<vc<<endl;
	if( vc <0 )
		if( AB(sx,sy,wx,wy)<=r+EPS )return true;
		else return false;
//	if( vc>=AB(sx,sy,tx,ty) )
	if( vc>=(sx-tx)*(sx-tx) + (sy-ty)*(sy-ty) )
		if( AB(sx,sy,wx,wy)<=r+EPS )return true;
		else return false;

    int cr = (tx-sx)*(wy-sy) - (ty-sy)*(wx-sx);
//    cout<<cr<<endl;
    double num = (double)cr/(double)( AB(tx,ty,sx,sy) );
//    cout<<fabs(num)<<" "<<r-EPS<<endl;
    if( fabs(num) < r+EPS )return true;

    return false;
}

int isInCircle(int wx,int wy,int r,  int tx,int ty,int sx,int sy){
    int ret=0;
    if( sqrt((wx-tx)*(wx-tx) + (wy-ty)*(wy-ty))<=r+EPS )ret++;
    if( sqrt((wx-sx)*(wx-sx) + (wy-sy)*(wy-sy))<=r+EPS )ret++;
    return ret;
}


int main(){
    while(1){
        int n,m;
        int wx[200],wy[200],r[200];
        int tx[1000],ty[1000],sx[1000],sy[1000];
        cin>>n;
        if(n==0)break;
        rep(i,n) cin>>wx[i]>>wy[i]>>r[i];

        cin>>m;
        rep(i,m) cin>>tx[i]>>ty[i]>>sx[i]>>sy[i];
    

        rep(i,m){
            bool flag=false;
            rep(j,n){
                int circle = isInCircle(wx[j],wy[j],r[j],tx[i],ty[i],sx[i],sy[i]);
                bool Cross = isCross(wx[j],wy[j],r[j],tx[i],ty[i],sx[i],sy[i]);
                if( (circle==0 && Cross) || circle==1 ){
                    flag = true;
                    break;
                }
            }
            if(flag)cout<<"Safe"<<endl;
            else cout<<"Danger"<<endl;
        } 
    }
}