#include <cstdio>
#include <cmath>

#define EPS 1e-10
int n,m;
double x[101],y[101],r[101];
double tx[101],ty[101],sx[101],sy[101];


struct vektor{
	double x,y;
	vektor(){}
	vektor(double xx,double yy){
		x=xx;
		y=yy;
	}

	double det(vektor p){
		return x*p.y-y*p.x;
	}
	double dot(vektor p){
		return x*p.x+y*p.y;
	}
	double len(){
		return sqrt(x*x+y*y);
	}
};


bool check(int v){
	for(int i=0;i<n;i++){
		double dt=sqrt((tx[v]-x[i])*(tx[v]-x[i])+(ty[v]-y[i])*(ty[v]-y[i]));
		double dr=sqrt((sx[v]-x[i])*(sx[v]-x[i])+(sy[v]-y[i])*(sy[v]-y[i]));
		if((dt-r[i])*(dr-r[i])<=0.0)return true;
		if(dt-r[i]>0 && dr-r[i]>0){
			vektor a=vektor(x[i]-sx[v],y[i]-sy[v]);
			vektor b=vektor(x[i]-tx[v],y[i]-ty[v]);
			vektor s=vektor(tx[v]-sx[v],ty[v]-sy[v]);
			double rr=fabs(s.det(a)/s.len());
			if(rr<=r[i]+EPS && s.dot(a)*b.dot(s)<=0)return true;
		}
	}
	return false;
}
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%lf %lf %lf",&x[i],&y[i],&r[i]);
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			scanf("%lf %lf %lf %lf",&tx[i],&ty[i],&sx[i],&sy[i]);
			printf("%s\n",check(i)?"Safe":"Danger");
		}
	}
	return 0;
}