#include <iostream>
#include <cmath>

using namespace std;

#define NMAX 100

struct S1{
	int wx, wy, r;
};

/*点と円 true->点は円の内部*/
bool po_cr(int cx, int cy, int cr, int px, int py){
	return pow((cx - px), 2.0) + pow((cy - py), 2.0) <= pow(cr, 2.0);
}

/*円と線 true->接している*/
bool li_cr(int cx, int cy, int cr,int lx1, int ly1, int lx2, int ly2){

	double A, B, C, CA, AS, BS;
	double d;

	A = pow(cx - lx1, 2.0) + pow(cy - ly1, 2.0);
	B = pow(cx - lx2, 2.0) + pow(cy - ly2, 2.0);
	C = pow(lx1 - lx2, 2.0) + pow(ly1 - ly2, 2.0);
	CA = (lx2 - lx1) * (cy - ly1) - (cx - lx1) * (ly2 - ly1);
	AS = (cx - lx1) * (lx2 - lx1) + (cy - ly1) * (ly2 - ly1);
	BS = (cx - lx2) * (lx2 - lx1) + (cy - ly2) * (ly2 - ly1);

	if(C != 0) d = pow(CA, 2.0) / C;
	else d = 0;

	if(d <= pow(cr, 2.0)){
		if(AS * BS <= 0){
			return 1;
		}
		else if(pow(cr, 2.0) > A || pow(cr, 2.0) > B){
			return 1;
		}
	}
	return 0;
}

int main(){

	int n, m;
	S1 wall[NMAX];
	int tx, ty, sx, sy;
	bool f;

	while(1){

		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; i++){
			cin >> wall[i].wx >> wall[i].wy >> wall[i].r;
		}

		cin >> m;

		for(int i = 0; i < m; i++){

			cin >> tx >> ty >> sx >> sy;

			f = true;
			for(int j = 0; j < n; j++){
				if(!po_cr(wall[j].wx, wall[j].wy, wall[j].r, sx, sy)){
					if(li_cr(wall[j].wx, wall[j].wy, wall[j].r, tx, ty, sx, sy)){
						f =  false;
					}
				}
				else if(!po_cr(wall[j].wx, wall[j].wy, wall[j].r, tx, ty)){
					f = false;
				}
			}

			if(f) cout << "Danger" << endl;
			else cout << "Safe" << endl;
		}
	}

}