#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 100000000
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1,Point p2):p1(p1),p2(p2){}
};
typedef Segment Line;

class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

double getDistanceSP(Segment s,Point p){
  if(dot(s.p2-s.p1,p-s.p1)<0.0)return abs(p-s.p1);
  if(dot(s.p1-s.p2,p-s.p2)<0.0)return abs(p-s.p2);
  return getDistanceLP(s,p);
}

bool iscross(Segment s,Circle c){
  if(abs(s.p1-c.c)<c.r && abs(s.p2-c.c)<c.r)return false;
  if(abs(s.p1-c.c)<c.r && abs(s.p2-c.c)>=c.r)return true;
  if(abs(s.p1-c.c)>=c.r && abs(s.p2-c.c)<c.r)return true;
  if(getDistanceSP(s,c.c)<=c.r)return true;
  return false;
}

int main()
{
  int n,m;

  while(1){
    cin>>n;
    if(n==0)break;
    vector<Circle> vc;
    vc.resize(n);
    for(int i=0;i<n;i++)cin>>vc[i].c.x>>vc[i].c.y>>vc[i].r;
    cin>>m;
    vector<Segment> vs;
    int x,y,a,b;
    for(int i=0;i<m;i++){
      cin>>x>>y>>a>>b;
      vs.push_back(Segment(Point(x,y),Point(a,b)));
    }

    for(int i=0;i<m;i++){
      bool flag=true;
      for(int j=0;j<n;j++){
	if(iscross(vs[i],vc[j]))flag=false;
      }
      if(flag)cout<<"Danger"<<endl;
      else cout<<"Safe"<<endl;
    }
  }
  return 0;
}