#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define SQ(x) ((x)* (x))

using namespace std;

// 円と線分の当たり判定 //
bool jES(int sx1, int sy1, int sx2, int sy2, int x, int y, int r) {
    int d2;
    int a,b, c;
	
	a = sy2 - sy1;
	b = sx1 - sx2;
	c = -1 * (a * sx1 + b * sy1);  
	// d = abs(a*x+b*y+c)/sqrt(a*a+b*b)
	d2 = SQ(a*x+b*y+c);
	if(d2 > r*r * (a*a + b*b)) return false;
	
	if(((sx2-sx1)*(x-sx1)+(sy2-sy1)*(y-sy1)>0) &&
	   ((sx1-sx2)*(x-sx2)+(sy1-sy2)*(y-sy2)>0))  return true;
	
	return false;
}


int main(void){
 
int n, m;
int w[110][3];
int tx,ty,sx,sy;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		rep(i,n) cin >> w[i][0] >> w[i][1]>> w[i][2];
		
		cin >> m;
		rep(i,m){
			cin >> tx >> ty >> sx >> sy;
			bool ok = true;
			rep(j,n){
				if((SQ(tx-w[j][0]) + SQ(ty-w[j][1]) < SQ(w[j][2])) &&
				(SQ(sx-w[j][0]) + SQ(sy-w[j][1]) < SQ(w[j][2]))) ok=false;
				else if ((SQ(tx-w[j][0]) + SQ(ty-w[j][1]) > SQ(w[j][2])) &&
				(SQ(sx-w[j][0]) + SQ(sy-w[j][1]) < SQ(w[j][2]))) ok=true;
				else if ((SQ(tx-w[j][0]) + SQ(ty-w[j][1]) < SQ(w[j][2])) &&
				(SQ(sx-w[j][0]) + SQ(sy-w[j][1]) > SQ(w[j][2]))) ok=true;
				else  ok = jES(tx,ty,sx,sy,w[j][0],w[j][1],w[j][2]);
		//		cout << "test:::" <<(ok?  "Safe": "Danger") << endl;
				if(ok) break;
			}
			cout << (ok? "Safe": "Danger") << endl;
		}
	}
}