#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()
typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
P projection(const L& l, const P& p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0]-p), abs(s[1]-p));
}
bool intersectCS(const C &c, const L &s){
    return (abs(c.p -s[0])+EPS > c.r || abs(c.p -s[1])+EPS > c.r)
        && distanceSP(s, c.p) < c.r +EPS;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<C> c(n);
        for(int i=0; i<n; i++){
            int x,y,r;
            cin >> x >> y >> r;
            c[i] = C(P(x,y), r);
        }

        int m;
        cin >> m;
        for(int i=0; i<m; i++){
            int sx,sy,tx,ty;
            cin >> sx >> sy >> tx >> ty;
            L s(P(sx,sy), P(tx,ty));
            bool safe = false;
            for(int j=0; j<n; j++){
                if(intersectCS(c[j], s)){
                    safe = true;
                    break;
                }
            }
            if(safe){
                cout << "Safe" << endl;
            }else{
                cout << "Danger" << endl;
            }
        }
    }
    return 0;
}

