#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <complex>
#include <cstdio>

using namespace std;
typedef complex<double> P;

struct circle{
  P p;
  double r;
  circle(const P &p, double r) : p(p), r(r){ }
};

int main(void){
  int n,m;
  int tmp1, tmp2, r;
  int x1,y1,x2,y2;
  double a,c,d,dt,dj;
  vector<circle> cvec;
  
  while(cin >> n && n){
	for(int i=0;i<n;i++){
	  cin >> tmp1 >> tmp2 >> r;
	  P p(tmp1, tmp2);
	  circle c(p,r);
	  cvec.push_back(c);
	}
	cin >> m;
	for(int i=0;i<m;i++){
	  bool isok = false;
	  cin >> x1 >> y1 >> x2 >> y2;
	  //calculate y = ax + b;
	  if(x1 != x2){
		a = (double)(y2 - y1) / (x2 - x1);
		c = y1 - a * x1;
		//printf("y = %lfx%+lf\n",a,c);
		for(int j=0;j<n;j++){
		  d = fabs(a*cvec[j].p.real()-1*cvec[j].p.imag()+c) / sqrt(a*a+1);
		  dt = sqrt((cvec[j].p.real() - x1) * (cvec[j].p.real() - x1) + 
					(cvec[j].p.imag() - y1) * (cvec[j].p.imag() - y1));
		  dj = sqrt((cvec[j].p.real() - x2) * (cvec[j].p.real() - x2) + 
					(cvec[j].p.imag() - y2) * (cvec[j].p.imag() - y2));

		  if(!((dt <= r && dj <= r) || d >= r)){
			isok = true;
		  }
		}
	  }else{
		for(int j=0;j<n;j++){
		  d = fabs(x1 - cvec[j].p.real());
		  dt = sqrt((cvec[j].p.real() - x1) * (cvec[j].p.real() - x1) + 
					(cvec[j].p.imag() - y1) * (cvec[j].p.imag() - y1));
		  dj = sqrt((cvec[j].p.real() - x2) * (cvec[j].p.real() - x2) + 
					(cvec[j].p.imag() - y2) * (cvec[j].p.imag() - y2));
		  if(!((dt <= r && dj <= r) || d >= r)){
			isok = true;
		  }
		}
	  }
	  if(isok){
		cout << "Danger" << endl;
	  }else{
		cout << "Safe" << endl;
	  }
	}
	cvec.clear();
  }
}