#include <iostream>
#include <vector>
#include <complex>
//#include <fstream>

using namespace std;

// deq notes ½Êô½É¨¯éxNgZ http://www.deqnotes.net/acmicpc/2d_geometry/

typedef complex<double> P;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

// àÏ (dot product) : a&#8901;b = |a||b|cosÆ
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}

// OÏ (cross product) : a~b = |a||b|sinÆ
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

// _cªüªa,bãÉ é©È¢©(2)
int is_point_on_line(P a, P b, P c) {
  // |a-c| + |c-b| <= |a-b| Èçüªã
  return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

// _a,bð[_Æ·éüªÆ_cÆÌ£
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

struct CIRCLE{
	P p;
	double r;
};

int main()
{
//	cut here before submit 
//	freopen("testcase.hide-and-seek", "r", stdin);
	int n, m;
	int i,j;

	while (cin >> n && n ) {
		vector <CIRCLE> c(n);
		for (i = 0; i < n; ++i ){
			cin >> c[i].p.real() >> c[i].p.imag() >> c[i].r;
		} // end for
		cin >> m;
		vector <P>  taro(m), oni(m);
		for (j = 0; j < m; ++j ){
			cin >> taro[j].real() >> taro[j].imag() >> oni[j].real() >> oni[j].imag();
		} // end for
		for (j = 0; j < m; ++j ){
			vector <bool> in_taro (n, false ), in_oni (n, false );
			for (i = 0; i < n; ++i ){
				double dis_t = abs (taro[j] - c[i].p );
				double dis_o = abs (oni[j] - c[i].p );
				if (dis_t < c[i].r ){ // in circle[i]
					in_taro[i] = true;
				} // end if
				if (dis_o < c[i].r ){
					in_oni[i] = true;
				} // end if
			} // end for
			bool match = true;
			for (i = 0; i < n; ++i ){
				if (in_taro[i] == in_oni[i] ){
					continue;
				}else{
					match = false;
					break;
				} // end if
			} // end for
			if (!match ){
				cout << "Safe" << endl;
				continue;
			} // end if

			bool found = true;
			for (i = 0; i < n; ++i ){
				double dis = distance_ls_p (taro[j], oni[j], c[i].p );
				if (!in_taro[i] && (is_point_on_line (taro[j], oni[j], c[i].p ) || dis <= c[i].r ) ) { 
					found = false;
					break;
				} // end if
			} // end for
			if (found ){
				cout << "Danger" << endl;
			}else{
				cout << "Safe" << endl;
			} // end if
		} // end for
	} // end loop
		
	return 0;
}