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

typedef complex<double> P;
typedef const P &rP;

#define EPS 1e-7

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

bool intersectlsc(rP p1, rP p2, rP pc, double r){
	P v12 = p2 - p1;
	P v1c = pc - p1;

	double a = norm(v12);
	double b = -dot(v12, v1c);
	double c = norm(v1c) - r * r;

	double D = b * b - a * c;

	if( D < -EPS ){
		return false;
	}
	else if( D < 0.0 ){
		D = 0.0;
	}

	double t1 = (-b + sqrt(D)) / a;
	double t2 = (-b - sqrt(D)) / a;

	if( (-EPS < t1 && t1 < 1.0 + EPS)
		|| (-EPS < t2 && t2 < 1.0 + EPS)
	){
		return true;
	}
	return false;
}

int n;
P w[100];
double r[100];

const char *solve(rP t, rP s){
	for(int i = 0; i < n; ++i){
		if( intersectlsc(t, s, w[i], r[i]) ){
			return "Safe";
		}
	}
	return "Danger";
}

int main(){
	int m;
	double x, y;
	double tx, ty, sx, sy;
	
	while( scanf("%d", &n), n != 0 ){
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf", &x, &y, &r[i]);
			w[i] = P(x, y);
		}
		
		scanf("%d", &m);
		for(int i = 0; i < m; ++i){
			scanf("%lf%lf%lf%lf", &tx, &ty, &sx, &sy);
			puts( solve( P(tx, ty), P(sx, sy) ) );
		}
	}
}