#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#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()

const double EPS = 1e-8;
const double INF = 1e12;

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

bool intersectSC(const L &s, const C &c) {
  if (abs(s[0]-c.p) < c.r && abs(s[1]-c.p) < c.r) return false; // ツ円ツづ個陳づ可禿シツづゥツづ個づ債古ーツ債キツづつキツづゥツつゥツつオツづ按つ「ツつゥツ。
  return distanceSP(s, c.p) <= c.r +EPS;
}

int main() {
  int n;
  while(cin >> n, n) {
    vector<C> v;
    REP(i,n) {
      double x,y,r;
      cin >> x >> y >> r;
      v.push_back(C(P(x,y),r));
    }
    int m;
    cin >> m;
    while(m--) {
      int tx,ty,sx,sy;
      cin >> tx >>ty >> sx >> sy;
      L l(P(tx,ty), P(sx,sy));
      bool danger = true;
      FOR(it, v) {
        if (intersectSC(l, *it)) {
          cout << "Safe" << endl;
          danger = false;
          break;
        }
      }
      if (danger) {
        cout << "Danger" << endl;
      }
    }
  }
}