#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define EPS (1e-10)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0

using namespace std;

class Point
{
  public:
  double x,y;
  Point(double x = -1,double y = -1): 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 a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}//※イケメンに限る

  bool operator < (const Point& p) const
  {
    return x != p.x?x<p.x:y<p.y;
  }

  bool operator == (const Point& p)const
  {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct Segment
{
  Point p1,p2;
  Segment(Point p1 = Point(-1,-1),Point p2 = Point(-1,-1)):p1(p1),p2(p2){}
};

typedef Segment Line;
typedef vector<Point> Polygon;

struct Circle
{
  double x,y,r;
  Circle(double x=-1,double y=-1,double r=-1):x(x),y(y),r(r){}
};

double dot(Point a,Point b)
{
  return a.x*b.x + a.y*b.y;
}
double cross(Point a,Point b)
{
  return a.x*b.y - a.y*b.x;
}

double norm(Point a)
{
  return a.x*a.x+a.y*a.y;
}

double abs(Point a)
{
  return sqrt(norm(a));
}

double getDistanceLP(Line s,Point p)
{
  return abs(cross(s.p2-s.p1,p-s.p1))/abs(s.p2-s.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 inCircle(Circle c,Point p)
{
  return sqrt(pow(p.x-c.x,2)+pow(p.y-c.y,2)) <= c.r;
}

bool check(Circle c,Segment s)
{
  if(inCircle(c,s.p1) && inCircle(c,s.p2))return false;
  double dist = getDistanceSP(s,Point(c.x,c.y));
  return dist <= c.r;
}

int main()
{
  int n,m;
  while(cin >> n,n)
    {
      vector<Circle> vec(n);
      for(int i=0;i<n;i++)cin >> vec[i].x >> vec[i].y >> vec[i].r;
      cin >> m;
      Segment s;
      for(int i=0;i<m;i++)
	{
	  cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
	  for(int j=0;j<n;j++)
	    {
	      if(check(vec[j],s))
		{
		  cout << "Safe" << endl;
		  goto F;
		}
	    }
	  cout << "Danger" << endl;
	F:;
	}
    }
  return 0;
}