#include <bits/stdc++.h>
using namespace std;

// infty
#define ULLINF (ULLONG_MAX)
#define LLINF  (LLONG_MAX)
#define IINF   (INT_MAX)
#define INF    (1<<29)

// math
#define Sq(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();it++)

// rep
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// pair util
#define FST first
#define SND second

// range validator
#define CK(n,a,b) (a<=n && n<b)

// conversion
template<class T> inline string toStr(T a) { ostringstream oss_; oss_ << a; return oss_.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

int const dx[] = {-1,0,1,0,-1,1,1,-1};
int const dy[] = {0,-1,0,1,-1,-1,1,1};

//////////////////////////////////////////////////////////////

#define EPS (1e-5)

typedef complex<double> P;
typedef pair<double, P> C;
typedef pair<P, P> S;

double dot(P a, P b) {
  return a.real()*b.real()+a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag()-a.imag()*b.real();
}

typedef S Line;
double distanceLP(Line l, P a) {
  P base = l.SND-l.FST;
  return cross(base, a-l.FST) / abs(base);
}

double distanceSP(S s, P a) {
  {
    P X = s.SND - s.FST, Y = a - s.FST;
    if(dot(X, Y) < EPS) return abs(Y);
  }
  {
    P X = s.FST - s.SND, Y = a - s.SND;
    if(dot(X, Y) < EPS) return abs(Y);
  }
  
  return distanceLP(s, a);
}

int main() {
  
  while(1) {
    int N;
    cin >> N; if(N == 0) break;
    
    vector<C> circles(N);
    
    for(int i=0; i<N; i++) {
      double x, y, r;
      cin >> x >> y >> r;
      circles[i] = C(r, P(x, y));
    }
    
    int Q; cin >> Q;
    while(Q--) {
      int x, y;
      cin >> x >> y; P taro(x, y);
      cin >> x >> y; P devil(x, y);
      
      bool ok = 0;
      for(int idx=0; idx<N; idx++) {
	if( distanceSP( S(taro, devil), circles[idx].SND ) < circles[idx].FST + EPS ) {
	  if( abs(taro-circles[idx].SND) > circles[idx].FST + EPS
	      || abs(devil-circles[idx].SND) > circles[idx].FST + EPS ) ok = 1;
	}
      }
      
      if(ok) cout << "Safe" << endl;
      else cout << "Danger" << endl;
    }
    
  }
  
  return 0;
}