#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EPS (1e-8)

typedef complex<double> P;
typedef complex<double> Vec;

struct Line {
	P p;
	Vec v;
	
	Line(P p, Vec v) : p(p), v(v) {}
	
	P getPoint(double t) {
		return p + v * t;
	}
};

struct Circle {
	P p;
	double r;
	
	Circle() {}
	Circle(P p, double r) : p(p), r(r) {}
};

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

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

bool isInCircle(P p, Circle c) {
	return norm(c.p - p) < c.r*c.r + EPS;
}

bool isIntersectionSC(Line s, Circle c) {
	if (isInCircle(s.p, c) && isInCircle(s.getPoint(1.0), c)) return false;
	
	Vec a = c.p - s.p, b = c.p - s.getPoint(1.0);
	
	if (dot(s.v, a) < -EPS) return abs(a) < c.r - EPS;
	if (dot(s.v, a) > dot(s.v, s.v) + EPS) return abs(b) < c.r - EPS;
	else return abs(cross(s.v, a)) / abs(s.v) < c.r + EPS;
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if (!n) break;
		
		Circle wall[100];
		REP(i, n) {
			double x, y, r;
			scanf("%lf %lf %lf", &x, &y, &r);
			wall[i] = Circle(P(x, y), r);
		}
		
		int m;
		cin >> m;
		REP(i, m) {
			double tx, ty, sx, sy;
			scanf("%lf %lf %lf %lf", &tx, &ty, &sx, &sy);
			
			Line s(P(sx, sy), P(tx, ty) - P(sx, sy));
			
			int flag = false;
			REP(j, n) if (isIntersectionSC(s, wall[j])) flag = true;
			
			if (flag) puts("Safe");
			else puts("Danger");
		}
	}
	return 0;
}