#include <cstdio>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define EPS 1e-8
typedef complex<double> P;

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

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

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

double dist(const P& a, const P& b)
{
	return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

bool isIntoC(const L& l, const C& c)
{
	return dist(l[0], c.p)+EPS < c.r && dist(l[1], c.p)+EPS < c.r;
}

bool intersectSC(const L& l, const C& c)
{
	if(isIntoC(l, c)) return false;
	
	double vc=dot(l[1]-l[0], c.p-l[0]);
	if(vc+EPS<0)
	{
		return dist(l[0], c.p)<c.r+EPS;
	}
	
	double vv=dot(l[1]-l[0], l[1]-l[0]);
	
	if(vc > vv)
	{
		double d=dist(l[1], c.p);
		
		return d*d<c.r*c.r+EPS;
	}
	
	double cc=dot(c.p-l[0], c.p-l[0]);
	
	return cc-(vc/vv)*vc < c.r*c.r+EPS;
}

int main()
{
	int N,M;
	
	while(scanf("%d", &N), N)
	{
		vector<C> walls;
		while(N--)
		{
			int x,y,r;
			scanf("%d%d%d", &x,&y,&r);
			walls.push_back(C(P(x,y), r));
		}
		
		scanf("%d", &M);
		while(M--)
		{
			int tx,ty,sx,sy;
			scanf("%d%d%d%d", &tx,&ty,&sx,&sy);
			bool g=false;
			for(int i=0; i<walls.size(); i++)
			{
				if(intersectSC(L(P(tx,ty),P(sx,sy)), walls[i]))
				{
					g=true;
					break;
				}
			}
			
			puts((g?"Safe":"Danger"));
		}
	}
}