#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second

const double EPS = 1e-10;
const double INF = 1e12;
typedef complex<double> P;
typedef pair<P,P> L;
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);
}

typedef vector<P> G;
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

P proj(P p, L l){
  return l.first + dot(p - l.first, l.second - l.first) / norm(l.second - l.first) * (l.second - l.first);
}

bool isIntersectSP(L s, P p) {
  return abs(s.F-p)+abs(s.S-p)-abs(s.S-s.F) < EPS;
}

vector<P> getIntersectCS(C c, L s){
  vector<P> res;
  P h = proj(c.p, s);
  double d = abs(c.p - h);
  if(d > c.r + EPS);
  else if(d > c.r - EPS){
    if(isIntersectSP(s,h)) res.push_back(h);
  }
  else {
    P v = s.second - s.first;
    v = (sqrt(c.r*c.r - d*d) / abs(v)) * v;
    if(isIntersectSP(s, h+v)) res.push_back(h+v);
    if(isIntersectSP(s,h-v)) res.push_back(h-v);
  }
  return res;
}

int main() {
  int n;
  while(cin >> n && n) {
    vector<C> c;
    rep(i,n) {
      double x,y,r;
      cin >> x >> y >> r;
      c.pb(C(P(x,y),r));
    }
    int m;
    cin >> m;
    rep(j,m) {
      L l;
      double x1,x2,y1,y2;
      cin >> x1 >> y1 >> x2 >> y2;
      l.F.real(x1);
      l.F.imag(y1);
      l.S.real(x2);
      l.S.imag(y2);
      int cnt=0;
      rep(i,n) {
	vector<P> v=getIntersectCS(c[i],l);
	cnt+=v.size();
      }
      if(!cnt) pr("Danger");
      else pr("Safe");
    }
  }
  return 0;
}
