#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

#define N_MAX 100

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); }
};
typedef Point Vector;

class Segment {
public:
  Point p1, p2;
  Segment(Point p1, Point p2) {
    this->p1 = p1;
    this->p2 = p2;
  }
};

typedef Segment Line;

class Circle {
public:
  Point o;
  double 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 getDistanceSP(Segment s, Point p) {
  if(dot(s.p2 - s.p1, p - s.p1) < 0) return abs(p - s.p1);
  if(dot(s.p1 - s.p2, p - s.p2) < 0) return abs(p - s.p2);
  return fabs(cross(s.p2 - s.p1, p - s.p1)) / abs(s.p2 - s.p1);
}

bool isInCircle(Circle c, Point p) {
  return c.r - abs(c.o - p) > 0;
}

vector<Circle> w(N_MAX);
Point t, s;


void solve() {
  {
    vector<Circle>::iterator it = w.begin();
    while(it != w.end()) {
      bool tic, sic;
      tic = isInCircle(*it, t);
      sic = isInCircle(*it, s);
      if(tic && sic) {
	it = w.erase(it);
      } else if(tic || sic) {
	cout << "Safe" << endl;
	return;
      } else {
	it++;
      }
    }
  }

  Segment u(t, s);
  for(int i = 0; i < w.size(); ++i) {
    if(w[i].r - getDistanceSP(u, w[i].o) >= 0) {
      cout << "Safe" << endl;
      return;
    }
  }
  cout << "Danger" << endl;
}

main() {
  int n;
  while((cin >> n) && n) {
    vector<Circle> v;
    for(int i = 0; i < n; ++i) {
      Circle c;
      cin >> c.o.x >> c.o.y >> c.r;
      v.push_back(c);
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; ++i) {
      w = v;
      cin >> t.x >> t.y >> s.x >> s.y;
      solve();
    }
  }
}