#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
double dot(double ax, double ay, double bx, double by) {
	return ax*bx+ay*by;
}
int main() {
	int n,m;
	while(cin >> n, n) {
		double x[100],y[100],r[100];
		rep(i,n) {
			cin >> x[i] >> y[i] >> r[i];
		}
		cin >> m;
		double tx,ty,sx,sy;
		rep(i,m) {
			cin >> tx >> ty >> sx >> sy;
			bool flag = 0;
			rep(j,n) {
				double vx1 = tx-sx, vy1 = ty-sy;
				double vx2 = x[j]-sx, vy2 = y[j]-sy;
				double slen = sqrt(vx2*vx2+vy2*vy2);
				double tlen = sqrt(pow(x[j]-tx,2)+pow(y[j]-ty,2));				
				if(slen<r[j] && tlen>r[j] || slen>r[j] && tlen<r[j]) {
					flag = 1;
					break;
				} else {
					double n1 = dot(vx1,vy1,vx2,vy2);
					double n2 =	dot(vx1,vy1,vx1,vy1);
					double n3 = dot(vx2,vy2,vx2,vy2);
					if(n1>0 && n2>n1 && !(tlen<r[j]&&slen<r[j]) && n3-(n1/n2)*n1<=r[j]*r[j]) {
						flag = 1;
						break;
					}
				}
			}
			if(flag) cout << "Safe" << endl;
			else cout << "Danger" << endl;
		}
	}
	return 0;
}