#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>

using namespace std;

int main() {
 int i,j,n,m,f;
 double a,b,c,r,mx[256],my[256],mr[256];
 vector<double> tx,ty,sx,sy;
 while(cin >> n) {
	 if (n==0) break;
	 for (i=0;i<n;i++)  cin >> mx[i] >> my[i] >> mr[i];
	 cin >> m;
	 for (i=0;i<m;i++) { cin >> a >> b >> c >> r; tx.push_back(a); ty.push_back(b); sx.push_back(c); sy.push_back(r);}
	 for (i=0;i<m;i++) { 
		 for (j=0,f=0;j<n;j++) {
			 a=sqrt((tx[i]-sx[i])*(tx[i]-sx[i])+(ty[i]-sy[i])*(ty[i]-sy[i]));
			 b=sqrt((tx[i]-mx[j])*(tx[i]-mx[j])+(ty[i]-my[j])*(ty[i]-my[j]));
			 c=sqrt((sx[i]-mx[j])*(sx[i]-mx[j])+(sy[i]-my[j])*(sy[i]-my[j]));
			 r=sqrt(c*c-(a*a-b*b+c*c)*(a*a-b*b+c*c)/(4*a*a));
			 if (b<mr[j] && c<mr[j]) continue;
			 if ((b<=mr[j] && c>mr[j]) || (b>mr[j] && c<=mr[j])) f=1;
             if (mr[j]+0.0001>=r && sqrt(b*b-r*r)+sqrt(c*c-r*r)<=a) f=1;
			 }
		 if (f==1) cout << "Safe" << endl; else cout << "Danger" << endl;
	 }
	 tx.clear(); ty.clear(); sx.clear(); sy.clear();
 }
 return 0;
}