#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;
/* àÏ */
static inline double inp(const P &a, const P &b){
  return (conj(a)*b).real();
}
/* OÏ */
static inline double outp(const P &a, const P &b){
  return (conj(a)*b).imag();
}

class Line{
public:
  P p; /* position */
  P d; /* direction */
  Line(){}
  Line(P pos, P dir){p=pos; d=dir/abs(dir);}
};

/* _Æûü©ç */
Line LineDirect(P pos, P dir){
  return Line(pos, dir);
}
/* 2_©ç */
Line LinePos(P p1, P p2){
  return Line(p1, p2-p1);
}

/* _Æ¼üÌ£ */
double dist(const Line &l, const P &p){
  return std::abs(outp(l.d, p-l.p) / abs(l.d));
}

P crossPoint(const Line &l1, const Line &l2){
  double num = outp(l2.d, l2.p-l1.p);
  double denom = outp(l2.d, l1.d);
  return P(l1.p + l1.d * num/denom);
}
int ccw(P p0, P p1, P p2){
  P d1 = p1-p0;
  P d2 = p2-p0;
  double dx1 = d1.real(), dx2 = d2.real();
  double dy1 = d1.imag(), dy2 = d2.imag();

  if(dx1*dy2 > dy1*dx2) return  1;//½vñè
  if(dx1*dy2 < dy1*dx2) return -1;//vñè
  if((dx1*dx2 < 0) || (dy1*dy2 < 0)) return -1;
  if((dx1*dx1+dy1*dy1) < (dx2*dx2+dy2*dy2)) return 1;
  return 0;
}

int main(){
  int n;
  scanf("%d",&n);
  P o[n];
  double r[n];
  REP(i,n)
    scanf("%lf%lf%lf",&o[i].real(),&o[i].imag(),&r[i]);
  int m;
  scanf("%d",&m);
  while(m --> 0){
    P p[2];
    scanf("%lf%lf%lf%lf",&p[0].real(),&p[0].imag(),&p[1].real(),&p[1].imag());

    bool ans = false;
    if(p[0] != p[1])
      REP(i,n){
        double d1 = abs(p[0] - o[i]) - r[i];
        double d2 = abs(p[1] - o[i]) - r[i];
        if((d1 < 0 && d2 > 0) || (d1 > 0 && d2 < 0)){
          ans = true;
          break;
        }
        if(d1 < 0 && d2 < 0)
          continue;
        if(dist(LinePos(p[0],p[1]), o[i]) > r[i])
          continue;

        Line l = LineDirect(o[i], (p[0]-p[1])*P(0,1));
        P pp = crossPoint(l, LinePos(p[0],p[1]));
        P l1 = pp - p[0];
        P l2 = pp - p[2];
        if((l1 / l2).real() < 0){
          ans = true;
          break;
        }
      }
    puts(ans?"Safe":"Danger");
  }
  return 0;
}