#include<vector>
#include<complex>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

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

typedef vector<P> G;

struct C {
  P p; double r;
  //C(const P &p, double r) : p(p), r(r) { }
};
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

bool inner(P &p, C &c){
	return norm(p-c.p)<(c.r)*(c.r)+EPS;
}
int main(){
	int m,n;
	double t1, t2, t3, t4;
	while(cin>>n,n){
		C wall[n];
		rep(i,n)cin>>t1>>t2>>t3,wall[i].p=P(t1,t2),wall[i].r=t3;
		cin>>m;
		rep(i,m){
			cin>>t1>>t2>>t3>>t4;
			P t=P(t1,t2),s=P(t3,t4),h,tmp;
			L l(t,s);
			bool danger=1;
			rep(j,n){
				h=projection(l,wall[j].p);
				if(intersectSP(l,h)){
					tmp=norm(t-wall[j].p)>norm(s-wall[j].p)?t:s;
					danger=danger&&(inner(tmp,wall[j])==inner(h,wall[j]));
				}else{
					danger=danger&&(inner(t,wall[j])==inner(s,wall[j]));
				}
			}
			cout<<(danger?"Danger":"Safe")<<endl;
		}
	}
	return 0;
}