#include <iostream>
#include <cmath>
using namespace std;

const double EPS = 1e-9;

struct Circle{
	int x;
	int y;
	int r;
};

struct Segment{
	int sx;
	int sy;
	int ex;
	int ey;
};

class Vector2{
public:
	Vector2( const int _x, const int _y ) : x( _x ), y( _y ){}
	int x;
	int y;

	int dotProduct( const Vector2& v )
	{
		return x * v.x + y * v.y;
	}
	int clossProduct( const Vector2& v )
	{
		return x * v.y - y * v.x;
	}
	double length()
	{
		return sqrt( static_cast<double>( x * x + y * y ) );
	}
};

int main()
{
	int n, m;
	while( cin >> n ){
		if( n == 0 ){
			break;
		}
		Circle* circles = new Circle[ n ];
		for( int i = 0; i < n; ++i ){
			cin >> circles[ i ].x >> circles[ i ].y >> circles[ i ].r;
		}

		cin >> m;
		if( m == 0 ){
			delete[] circles;
			continue;
		}
		Segment seg;
		for( int i = 0; i < m; ++i ){
			cin >> seg.sx >>seg.sy >> seg.ex >> seg.ey;
			bool safety = false;

			for( int j = 0 ; j < n; ++j ){
				Circle* cir = &circles[ j ];
				bool collision = false;

				Vector2 se( seg.ex - seg.sx, seg.ey - seg.sy );
				Vector2 sc( cir->x - seg.sx, cir->y - seg.sy );
				Vector2 ec( cir->x - seg.ex, cir->y - seg.ey );
				double d = se.clossProduct( sc ) / se.length();
				if( !( sc.length() + EPS < static_cast<double>( cir->r )
					&& ec.length() + EPS < static_cast<double>( cir->r ) ) ){
					if( d <= static_cast<double>( cir->r ) + EPS ){
						if( sc.dotProduct( se ) * ec.dotProduct( se ) <= 0 ){
							collision = true;
						}else if( sc.length() + EPS < static_cast<double>( cir->r )
							|| ec.length() + EPS < static_cast<double>( cir->r ) ){
							collision = true;
						}
					}
				}
				if( collision ){
					safety = true;
					break;
				}
			}
			cout << ( safety ? "Safe" : "Danger" ) << endl;
		}
		delete[] circles;
	}
	return 0;
}