#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;



//??????
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int i = 1; i < N; i++) cout << ", " << v[i]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> pii;
typedef pair<pii, int> pi3;

bool inCircle(pi3 circle, pii point)
{
	int cx = circle.first.first;
	int cy = circle.first.second;
	int r = circle.second;
	int x = point.first;
	int y = point.second;

	return ((cx - x) * (cx - x) + (cy - y) * (cy - y) < r * r);
}

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

		vector<pi3> w(n);
		for (int i = 0; i < n; i++) cin >> w[i].first.first >> w[i].first.second >> w[i].second;

		int m;
		cin >> m;
		
		for (int i = 0; i < m; i++) {
			int tx, ty, sx, sy;
			cin >> tx >> ty >> sx >> sy;
			string t_state, s_state;
			for (int j = 0; j < n; j++) {
				t_state.push_back((inCircle(w[j], pii(tx, ty)) ? '1' : '0'));
				s_state.push_back((inCircle(w[j], pii(sx, sy)) ? '1' : '0'));
			}
			if (t_state != s_state) {
				cout << "Safe" << endl;
				continue;
			}

			bool danger = true;
			for (int j = 0; j < n; j++) {
				// ???????????¨???????????´??????????????????
				if (t_state[j] == '1') continue;

				int cx = w[j].first.first;
				int cy = w[j].first.second;
				int r = w[j].second;

				int dct, dts, dsc;
				dct = (cx - tx) * (cx - tx) + (cy - ty) * (cy - ty);
				dts = (tx - sx) * (tx - sx) + (ty - sy) * (ty - sy);
				dsc = (sx - cx) * (sx - cx) + (sy - cy) * (sy - cy);

				if (dct + dts <= dsc || dsc + dts <= dct) continue;

				int a = sy - ty;
				int b = tx - sx;
				int c = sy * (sx - tx) - sx * (sy - ty);

				// r < d
				if (r * r * (a * a + b * b) < (a * cx + b * cy + c) * (a * cx + b * cy + c)) continue;
				
				danger = false;
				break;
			}

			cout << (danger ? "Danger" : "Safe") << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 2972