#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-8

using namespace std;

struct Point 
{
    double x, y;
    Point(double x=0, double y=0) : x(x), y(y) {}

    Point operator+(const Point &o) const 
	{
        return Point(x+o.x, y+o.y);
    }

    Point operator-(const Point &o) const 
	{
        return Point(x-o.x, y-o.y);
    }
 
    Point operator*(const double m) const 
	{
        return Point(x*m, y*m);
    }
 
    Point operator/(const double d) const 
	{
        return Point(x/d, y/d);
    }

	bool operator < (const Point &a) const
	{
		return x == a.x ? y < a.y : x < a.x;
	}
 
    double cross(const Point &o) const 
	{
        return x * o.y - y * o.x;
    }
 
    double dot(const Point &o) const 
	{
        return x * o.x + y * o.y;
    }
 
    double atan() const 
	{
        return atan2(y, x);
    }

    double norm() const 
	{
        return dot(*this);
    }

	double distance (const Point &o) const 
	{
        return sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y));
    }

	double distance_Line(const Point &a,const Point &b) const
	{
		Point p(x,y);

		Point d = b-a;

		if(d.x == 0 && d.y == 0)
		{
			return p.distance(a);
		}

		double r2 = d.x*d.x + d.y*d.y;
		double t = (d.x*(p.x - a.x) + d.y*(p.y - a.y)) / r2;

		if(t < 0)
		{
			return p.distance(a);
		}
		if(t > 1)
		{
			return p.distance(b);
		}

		Point c;
		c.x = (1-t) * a.x + t*b.x;
		c.y = (1-t) * a.y + t*b.y;
		return p.distance(c);
	}

	double area(const Point &a,const Point &b) const
	{
		double t = (a.x - x) * (b.y - y);
		double t2 = (a.y - y) * (b.x - x);
		double areas = abs(t-t2);
		return  areas/2;
	}
};


int main()
{
	int n;
	vector<Point> kp;
	vector<double> r;

	while(cin >> n && n)
	{
		double a,b,c,d;
		
		rep(i,n)
		{
			cin >> a>> b >> c;
			kp.push_back(Point(a,b));
			r.push_back(c);
		}

		int m;
		cin >> m;
		rep(i,m)
		{
			cin >> a >> b >> c >> d;
			Point p1(a,b);
			Point p2(c,d);

			bool flag = true;
			rep(j,kp.size())
			{
				double d1 = p1.distance(kp[j]);
				double d2 = p2.distance(kp[j]);

				if(d1 > r[j] + EPS && d2 < r[j] + EPS)
				{
					flag = false;
					cout << "Safe" << endl;
					break;
				}
				else if(d1 < r[j] + EPS && d2 > r[j] + EPS)
				{
					flag = false;
					cout << "Safe" << endl;
					break;
				}

				else if(d1 > r[j] && d2 > r[j])
				{
					double dd = kp[j].distance_Line(p1,p2);

					if(dd < r[j] + EPS)
					{
						flag = false;
						cout << "Safe" << endl;
						break;
					}
				}
			}
			if(flag)
			{
				std::cout << "Danger" << endl;
			}
		}


	}
	return 0;
}