#include<cstdio>
#include<vector>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

template<class T>
struct point{
	T x,y;
	point operator-(const point &a)const{ return (point){x-a.x,y-a.y}; }
};

template<class T>
struct segment:vector< point<T> >{
	segment(const point<T> &a,const point<T> &b){ push_back(a), push_back(b); }
};

template<class T>
struct circle{
	point<T> c;
	T r;
};

template<class T>
T dot(const point<T> &a,const point<T> &b){ return a.x*b.x+a.y*b.y; }

template<class T>
T cross(const point<T> &a,const point<T> &b){ return a.x*b.y-a.y*b.x; }

template<class T>
T dist2(const point<T> &a,const point<T> &b){
	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

template<class T>
T dist2(const segment<T> &S,const point<T> &p){
	if(dot(S[1]-S[0],p-S[0])<=0) return dist2(p,S[0]);
	if(dot(S[0]-S[1],p-S[1])<=0) return dist2(p,S[1]);
	return cross(S[1]-S[0],p-S[0])*cross(S[1]-S[0],p-S[0])/dist2(S[0],S[1]);
}

template<class T>
bool intersect(const circle<T> &C,const segment<T> &S){
	return dist2(S,C.c)<=C.r*C.r;
}

template<class T>
bool cover(const circle<T> &C,const point<T> &p){
	return dist2(C.c,p)<=C.r*C.r;
}

template<class T>
bool cover(const circle<T> &C,const segment<T> &S){
	return cover(C,S[0]) && cover(C,S[1]);
}

int main(){
	for(int n;scanf("%d",&n),n;){
		circle<int> C[100];
		rep(i,n) scanf("%d%d%d",&C[i].c.x,&C[i].c.y,&C[i].r);

		int m; scanf("%d",&m);
		while(m--){
			point<int> p,q;
			scanf("%d%d%d%d",&p.x,&p.y,&q.x,&q.y);
			segment<int> S(p,q);
			bool ok=false;
			rep(i,n) if(intersect(C[i],S) && !cover(C[i],S)) ok=true;
			puts(ok?"Safe":"Danger");
		}
	}

	return 0;
}