#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int wx[100],wy[100],r[100];

main(){
  int n;
  while(cin>>n,n){
    rep(i,n)cin>>wx[i]>>wy[i]>>r[i];

    int m;
    cin>>m;
    while(m--){
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      bool safe=false;
      rep(i,n){
	int e=wx[i],f=wy[i],g=r[i];
	bool myin=(e-a)*(e-a)+(b-f)*(b-f)<g*g;
	bool enin=(e-c)*(e-c)+(f-d)*(f-d)<g*g;
	if(myin!=enin){
	  safe=true;
	  break;
	}
	int var1=(-2*a*a*e+2*a*b*d-2*a*b*f+4*a*c*e-2*a*d*d+2*a*d*f-2*b*b*c+2*b*c*d+2*b*c*f-2*c*c*e-2*c*d*f);
	int var2=var1*var1-4*(a*a-2*a*c+b*b-2*b*d+c*c+d*d)*
	  (a*a*d*d-2*a*a*d*f+a*a*e*e+a*a*f*f-a*a*g*g-2*a*b*c*d+2*a*b*c*f+2*a*c*d*f
	   -2*a*c*e*e-2*a*c*f*f+2*a*c*g*g+b*b*c*c-2*b*c*c*f+c*c*e*e+c*c*f*f-c*c*g*g);
	if(var2<0)continue;
	int var3=2*a*a*e-2*a*b*d+2*a*b*f-4*a*c*e+2*a*d*d-2*a*d*f+2*b*b*c-2*b*c*d-2*b*c*f+
	  2*c*c*e+2*c*d*f;
	int var4=2*(a*a-2*a*c+b*b-2*b*d+c*c+d*d);
	double x1=double(sqrt(var2)+var3)/var4;
	double x2=double(-sqrt(var2)+var3)/var4;
	if((a<=x1 && x1<=c) || (c<=x1 && x1<=a) || (a<=x2 && x2<=c) || (c<=x2 && x2<=a)){
	  safe=true;
	  break;
	}
      }
      if(safe)cout<<"Safe"<<endl;
      else cout<<"Danger"<<endl;
    }
  }
}