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

typedef complex<double> P;

#define EPS (1e-10)

double dot(P a,P b){
	return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a,P b){
	return (a.real() * b.imag() - a.imag() * b.real());
}

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

bool intersected(P a,P b,P o,double r){
	double ao = abs(a-o);
	double bo = abs(b-o);
	if( (ao<r && bo>r || ao>r && bo<r) ||
		  (ao>r && bo>r && distance_ls_p(a,b,o) <= r) )
		return true;

	return false;
}

int main(void){
	int n,m;

	while(cin>>n && n){
		P o[n];
		double r[n];

		for(int i=0;i<n;i++){
			cin>>o[i].real()>>o[i].imag()>>r[i];
		}

		cin>>m;
		while(m--){
			P taro,oni;
			cin>>taro.real()>>taro.imag()>>oni.real()>>oni.imag();

			bool flg = true;
			for(int i=0;i<n;i++){
				if(intersected(taro,oni,o[i],r[i])){
					flg = false;
					break;
				}
			}

			if(flg) cout<<"Danger\n";
			else cout<<"Safe\n";
		}
	}

	return 0;
}