#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;
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 intersectSC2(const L &s, const C &c) { // î{IÈ­zÍãÆ¯¶¾ªA]vÈÖðìéKvªÈ­Èé
  if (abs(s[0]-c.p) < c.r && abs(s[1]-c.p) < c.r) return false; // ~ÌÉüéÌÍð·Æ·é©µÈ¢©B
  P vc = c.p-s[0], vs = s[1]-s[0];
  if (dot(vc,vs) < 0) // n_æèàO 
    return abs(vc) < c.r + EPS;
  if (dot(c.p-s[1],-vs) < 0) // I_æèàO
    return abs(c.p-s[1]) < c.r + EPS;
  return norm(vc)-dot(vc,vs)/norm(vs)*dot(vc,vs) < c.r*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 (intersectSC2(l, *it)) {
          cout << "Safe" << endl;
          danger = false;
          break;
        }
      }
      if (danger) {
        cout << "Danger" << endl;
      }
    }
  }
}