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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
int sign(double x){
  if(x > EPS) return 1;
  if(x < -EPS) return -1;
  return 0;
}
typedef complex<double> Point;
struct Line : public vector<Point> {
  Line(const Point& a, const Point& b){
    push_back(a); push_back(b);
  }
  Point vector() const {
    return back() - front();
  }
};
struct Circle{
  Point c;
  double r;
  Circle() {}
  Circle(Point c, double r) : c(c), r(r) {}
};

double dot(Point a, Point b){
  return real(conj(a) * b);
}
double cross(Point a, Point b){
  return imag(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
  b -= a; c -= a;
  if(cross(b, c) > EPS) return +1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}


bool intersectSP(const Line& s, const Point& p){
  return ccw(s[0], s[1], p) == 0;
}

Point projection(const Line& l, const Point& p){
  double t = dot(p - l[0], l.vector()) / norm(l.vector());
  return l[0] + t * l.vector();
}

double distanceSP(const Line& s, const Point& p){
  const Point r = projection(s, p);
  if(intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

enum{ OUT, ON, IN };
int contains(const Circle& C, const Point& p){
  double d = abs(C.c - p);
  if(sign(d - C.r) > 0) return OUT;
  if(sign(d - C.r) == 0) return ON;
  return IN;
}

bool intersectCS(const Circle& C, const Line& l){
  int b[2];
  REP(i, 2) b[i] = contains(C, l[i]);
  if(b[0] > b[1]) swap(b[0], b[1]);
  if(b[0] == OUT && b[1] == IN) return true;
  if(b[0] == IN && b[1] == IN) return false;
  if(b[0] == ON) return true;
  double d = distanceSP(l, C.c);
  if(sign(d - C.r) > 0) return false;
  return true;
}

int main(){
  int N;
  while(cin >> N && N){
    vector<Circle> WALL(N);
    REP(i, N) cin >> WALL[i].c.real() >> WALL[i].c.imag() >> WALL[i].r;
    int M;
    cin >> M;
    Point p[2];
    REP(i, M){
      REP(j, 2) cin >> p[j].real() >> p[j].imag();
      bool danger = true;
      REP(j, N) if(intersectCS(WALL[j], Line(p[0], p[1]))) danger = false;
      if(danger) cout << "Danger" << endl;
      else cout << "Safe" << endl;
    }
  }
  return 0;
}