#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int f(int k) { return k * k; }
signed main() {
	int n, q, x0[110], y0[110], r[110], x1, x2, y1, y2;
	while (cin >> n, n) {
		for1(i, n)cin >> x0[i] >> y0[i] >> r[i];
		cin >> q;
		while (q--) {
			cin >> x1 >> y1 >> x2 >> y2;
			bool b = 0;
			for1(i, n) {
				if ((f(x1 - x0[i]) + f(y1 - y0[i]) - f(r[i])) < 0 && (f(x2 - x0[i]) + f(y2 - y0[i]) - f(r[i])) < 0)continue;
				if ((f(x1 - x0[i]) + f(y1 - y0[i]) - f(r[i])) * (f(x2 - x0[i]) + f(y2 - y0[i]) - f(r[i])) < 0)b = 1;
				else if (f((y1 - y2) * x0[i] - (x1 - x2) * y0[i] + x1 * y2 - x2 * y1) <= f(r[i]) * (f(x1 - x2) + f(y1 - y2)) && ((x1 - x2) * (x0[i] - x1) + (y1 - y2) * (y0[i] - y1)) * ((x1 - x2) * (x0[i] - x2) + (y1 - y2) * (y0[i] - y2)) <= 0)b = 1;
				if (b)break;
			}
			cout << (b ? "Safe\n" : "Danger\n");
		}
	}
}
