#include <bits/stdc++.h>
#define ONLINE_JUDGE

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)

#ifdef ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif

#define pb emplace_back
#define lb lower_bound
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

#define ALL(c) (c).begin(),(c).end()

#define DBG0(x)    {if(DEBUG){ cout << #x << ": " << x << "\t"; }}
#define DBG(x)     {if(DEBUG){DBG0(x); cout << endl;}}
#define DBG2(x, y) {if(DEBUG){DBG0(x); DBG(y);}}
#define DBG3(x, y, z) {if(DEBUG){DBG0(x); DBG2(y, z);}}
#define DBG4(w, x, y, z) {if(DEBUG){DBG0(w); DBG3(x, y, z);}}

template <class T>
ostream& operator<<(ostream& os, vector<T> xs){ for(T x: xs) os << x << ' '; return os; }
template <class S, class T>
ostream& operator<<(ostream& os, pair<S,T> st){ os << "(" << st.first << "," << st.second <<")"; return os; }

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

/* Library starts here */
const double EPS = 1.0e-14;
typedef complex<double> Point;
/* Line is represented as (a, b, c) of ax + by + c = 0 */
typedef tuple<double, double, double> Line;
/* Circle is represented as ((a, b), r) of (x - a)^2 + (y - b)^2 = r^2 */
typedef tuple<Point, double> Circle;
/* Line segment is represented as (P1, P2) */
typedef tuple<Point, Point> Line_segment;

const Point O(0.0,0.0);

istream& operator>>(istream& is, Point &pt){
    double a, b;
    is >> a >> b;
    pt.real(a); pt.imag(b);
    return is;
}

ostream& operator<<(ostream& os, const Point &pt){
    os << make_pair(pt.real(), pt.imag());
    return os;
}

ostream& operator<<(ostream& os, const Line &l){
    os << "(" << get<0>(l) << "," << get<1>(l) << "," << get<2>(l) << ")";
    return os;
}

ostream& operator<<(ostream& os, const Line_segment &l){
    os << "(" << get<0>(l) << "," << get<1>(l) << ")";
    return os;
}

ostream& operator<<(ostream& os, const Circle &c){
    os << "(" << get<0>(c) << "," << get<1>(c) << ")";
    return os;
}

inline double cross(const Point &a, const Point &b){
    return (a.real()*b.imag() - a.imag()*b.real());
}

inline double myarg(Point &a){
    double ret = arg(a);
    return (ret >= 0 ? ret : ret + 2*M_PI);
}

inline double signed_area(const Point &a, const Point &b, const Point &c){
    Point ab = b - a;
    Point ac = c - a;
    return cross(ab, ac) / 2.0;
}


void sort_by_arg(vector<Point> &pts){
    sort(pts.begin(), pts.end(), [](Point a, Point b){ return (myarg(a) < myarg(b)); });
}

inline Line make_line(const Point &a, const Point &b){
    return make_tuple(a.imag() - b.imag() , b.real() - a.real(), -(a.imag() * b.real() - a.real() * b.imag()));
}

inline Line orthogonal_line(const Point &p, const Line &l){
    return make_tuple(get<1>(l), -get<0>(l), get<0>(l) * p.imag() - get<1>(l) * p.real());
}

inline bool is_parallel(const Line &l0, const Line &l1){
    return ((get<0>(l0)*get<1>(l1) - get<1>(l0)*get<0>(l1)) == 0.0);
}

inline Point intersection_point(const Line &l0, const Line &l1){
    const double A = get<0>(l0);
    const double B = get<1>(l0);
    const double C = get<0>(l1);
    const double D = get<1>(l1);
    const double U = get<2>(l0);
    const double V = get<2>(l1);
    const double det = A*D - B*C;
    return Point((-D*U + B*V) / det,
                 ( U*C - A*V) / det);
}

inline Point rotate(const Point &p, const double theta){
    double ct = cos(theta);
    double st = sin(theta);
    return Point(ct * p.real() - st*p.imag(), st*p.real() + ct*p.imag());
}

/* whether polygon is_included p. It is considered true if p is on the edge. */
/* this function has not been validated */
bool is_included(const Point &p, const vector<Point> &polygon){
    int n = polygon.size();
    int zero = 0;
    int plus = 0;
    rep(i, n){
        const int di = (i + 1 == n ? 0 : i + 1);
        double tmp = cross(polygon[di] - polygon[i], p - polygon[i]);
        if(abs(tmp) <= 1e-14) zero++;
        else if(tmp > 0.0) plus++;
    }
    if(zero || plus == 0 || plus == n) return true;
    return false;
}

/* this function has not been validated */
inline bool is_included(const Point &P, const Line &L){
    return (P.real() * get<0>(L) + P.imag() * get<1>(L) + get<2>(L) == 0.0);
}

/* this function has not been validated */
bool is_included(const Point &P, const Line_segment &AB){
    const Point A = get<0>(AB), B = get<1>(AB);
    return (abs(P - A) + abs(B - P) - abs(B - A) < EPS);
}

/* this function has not been validated */
inline bool is_included(const Point &p, const Circle &cir){
    return (abs(p - get<0>(cir)) <= get<1>(cir));
}

double distance(const Point &P, const Line &L){
    return abs(P.real()*get<0>(L) + P.imag()*get<1>(L) + get<2>(L)) / abs(P);
}

/* distance between a point P and line segment AB */
/* this function has not been validated */
double distance(const Point &P, const Line_segment &AB){
    Line LAB = make_line(get<0>(AB), get<1>(AB));
    Line orth = orthogonal_line(P, LAB);
    Point S = intersection_point(orth, LAB);
    if(is_included(S, AB)) return abs(P - S);
    return min(abs(P - get<0>(AB)), abs(P - get<1>(AB)));
}

bool intersect(const Line_segment &AB, const Line &L){
    const Point A = get<0>(AB), B = get<1>(AB);
    const double a = get<0>(L);
    const double b = get<1>(L);
    const double c = get<2>(L);
    const double t = (a*A.real() + b*A.imag() + c) / (a*A.real() + b*A.imag() - (a*B.real() + b*B.imag()));
    return (0.0 <= t && t <= 1.0);
}

inline bool intersect(const Line_segment &AB, const Line_segment &CD){
    const Point A = get<0>(AB);
    const Point B = get<1>(AB);
    const Point C = get<0>(CD);
    const Point D = get<1>(CD);
    const Point VAB = B - A;
    const Point VCD = D - C;
    return ((cross(VAB, C - A) * cross(VAB, D - A) < 0.0) &&
            (cross(VCD, A - C) * cross(VCD, B - C) < 0.0));
}

/* this function has not been validated */
inline int num_of_intersection(const Line &L, const Circle &C){
    const double dis = distance(get<0>(C), L);
    if(abs(get<1>(C) - dis) < EPS ) return 1;
    if(get<1>(C) < dis) return 0;
    return 2;
}

inline int num_of_intersection(const Line_segment &AB, const Circle &C){
    const double PA = abs(get<0>(C) - get<0>(AB));
    const double PB = abs(get<0>(C) - get<1>(AB));
    const double r = get<1>(C);
    if(PA - r < 0.0 && PB - r < 0.0) return 0;
    if((PA - r < 0.0 && r - PB < 0.0) ||
       (PB - r < 0.0 && r - PA < 0.0)) return 1;
    const double mindis = distance(get<0>(C), AB);
    if(abs(mindis - r) < EPS) return 1;
    if(mindis - r < 0.0) return 2;
    return 0;
}

/* End of the Library */
int main(void){
    while(1){
        int n;
        cin >> n;
        if(!n) return 0;
        vector<Circle> vc(n);
        rep(i, n){
            Point p;
            int r;
            cin >> p >> r;
            vc[i] = Circle(p, r);
        }
        int m;
        cin >> m;
        rep(i, m){
            Point A, B;
            cin >> A >> B;
            Line_segment LAB(A, B);
            int sum = 0;
            rep(i, n){
                int ret = num_of_intersection(LAB, vc[i]);
                DBG3(LAB, vc[i], ret);
                sum += ret;
            }
            if(sum) cout << "Safe" << endl;
            else cout << "Danger" << endl;
        }
    }
    return 1;
}