#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-5;

using namespace std;

typedef complex<double> Point;

double dot(const Point& a, const Point& b)
{
	return a.real()*b.real() + a.imag()*b.imag();
}
double cross(const Point& a, const Point& b)
{
	return a.real()*b.imag() - a.imag()*b.real();
}
double distance_line_point(const Point& a, const Point& b, const Point& point)
{
	return abs(cross(a-b, point-b) / abs(a-b));
}
double distance_linesegment_point(const Point& a, const Point& b, const Point& point)
{
	if (dot(b-a, point-a) < Eps)
		return abs(a-point);
	else if (dot(a-b, point-b) <Eps)
		return abs(b-point);
	else
		return distance_line_point(a, b, point);
}

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		Point wall[126];
		int radius[126];
		for (int i = 0; i < n; ++i)
		{
			int a, b, r;
			scanf("%d %d %d", &a, &b, &r);
			wall[i] = Point(a, b);
			radius[i] = r;
		}

		int m;
		scanf("%d", &m);
		for (int i = 0; i < m; ++i)
		{
			int a, b, c, d;
			scanf("%d %d %d %d", &a, &b, &c, &d);
			Point tarou(a, b), oni(c, d);

			bool safe = false;
			for (int j = 0; j < n; ++j)
			{
				double EpsR = Eps + radius[j];
				if (abs(tarou - wall[j]) < EpsR && abs(oni - wall[j]) < EpsR)
					continue;

				if (distance_linesegment_point(tarou, oni, wall[j]) < EpsR)
				{
					safe = true;
					break;
				}
			}
			if (safe)
				puts("Safe");
			else
				puts("Danger");
		}
	}

	return 0;
}