#include<iostream>
#include<complex>
#include<algorithm>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;
typedef complex<double> P;
typedef pair<double,double> point;


double dot(P a,P b){
	return real(conj(a)*b);
}

double cross(P a,P b){
	return imag(conj(a)*b);
}

double dist(P a, P b,P c){
	if(dot(b-a,c-a)<0)return abs(c-a);
	if(dot(a-b,c-b)<0)return abs(c-b);
	return abs(cross(c-a,b-a))/abs(b-a);
}

int main(){
	int n,m;
	double x,y,r;
	P taro,oni;
	vector<pair<P,double> > circle; 
	while(cin>>n,n){
		circle.clear();
		rep(i,n){
			cin>>x>>y>>r;
			circle.pb(pair<P,double>(P(x,y),r));
		}
		cin>>m;
		rep(p,m){
			cin>>x>>y;
			taro=P(x,y);
			cin>>x>>y;
			oni=P(x,y);
			bool check=false;
			rep(i,n){
				r=circle[i].second;
				double d=dist(taro,oni,circle[i].first);
				if(d<=r && (abs(taro-circle[i].first)>=r || abs(oni-circle[i].first)>=r)){
					check=true;
					break;
				}
			}
			if(check)cout<<"Safe"<<endl;
			else cout<<"Danger"<<endl;
		}
	}
	return 0;
}