#include <iostream>
#include <cmath>
using namespace std;

#define N 100
#define rep(i, n) for(int i=0; i<n; i++)
#define pow2(x) ((x)*(x))
#define S "Safe\n"
#define D "Danger\n"

int dist(int x1,int y1,int x2,int y2){
	return pow2(x1-x2)+pow2(y1-y2);
}

int main(){
	int n,m;
	int wx[N],wy[N],r[N];
	bool safe;
	int tx,ty,sx,sy;
	while(cin>>n,n){
		rep(i,n){
			cin>>wx[i]>>wy[i]>>r[i];
			r[i]*=r[i];
		}
		cin>>m;
		rep(i,m){
			cin>>tx>>ty>>sx>>sy;
			int dx=sx-tx,dy=sy-ty;
			safe=0;
			rep(j,n){
				if((dist(tx,ty,wx[j],wy[j])<=r[j])^(dist(sx,sy,wx[j],wy[j])<=r[j])){
					safe=1;
					break;
				}
				//この先危険
				//http://marupeke296.com/COL_2D_No5_PolygonToCircle.html
				int t0=pow2(dx)+pow2(dy);
				int t1=-(dx*(tx-wx[j])+dy*(ty-wy[j]));
				if(!(dist(sx,sy,wx[j],wy[j])<=r[j])&&!(dist(tx,ty,wx[j],wy[j])<=r[j])&&0<=t1&&t1<=t0&&pow2( dx*(ty-wy[j]) - dy*(tx-wx[j]) ) <= t0*r[j]){
					safe=1;
					break;
				}
			}
			cout<<(safe?S:D);
		}
	}
	
	return 0;
}
