#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}

xy_t center[200];
double r[200];

int main(){
	int n, m;
	double wx, wy, tx, ty, sx, sy;
	while(cin >> n && n){
		rep(i, n){
			cin>> wx >> wy >> r[i];
			center[i] = xy_t(wx, wy);
		}
		cin >> m;
		rep(i, m){
			cin >> tx >> ty >> sx >> sy;
			line ls = line(xy_t(tx, ty), xy_t(sx, sy));
			bool ok = true;
			rep(j, n){
				if(distanceSP(ls, center[j]) < r[j] + EPS &&
					max(abs(center[j] - ls.first), abs(center[j] - ls.second)) > r[j] - EPS){
						//cout << center[j] << " " << distanceSP(ls, center[j]) << endl;
						ok = false;
				}
			}
			if(!ok) cout << "Safe" << endl;
			else cout << "Danger" << endl;
		}
	}
	return 0;
}