#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>


#define EPSILON 1e-9


class vector_t {
public:
  double x;
  double y;
  double z;

public:
  vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {};

public:
  double operator*(const vector_t& v) const {
    return x * v.x + y * v.y + z * v.z;
  };

  vector_t operator^(const vector_t& v) const {
    return vector_t(y * v.z - z * v.y,
                    z * v.x - x * v.z,
                    x * v.y - y * v.x);
  };

public:
  double length() const {
    return sqrt(*this * *this);
  };
};


class point_t {
public:
  double x;
  double y;
  double z;
  double w;

public:
  point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {};
  
public:
  vector_t operator-(const point_t& p) const {
    return vector_t(x - p.x, y - p.y, z - p.z);
  };
};


class point_circle_intersect : public std::unary_function<point_t, bool>
{
public:
  point_circle_intersect(const point_t& o, double r) : o_(o), rr_(r * r + EPSILON) {};

public:
  bool operator()(const point_t& p) const {
    vector_t v(p - o_);

    return v * v < rr_;
  };

private:
  point_t o_;
  
  double rr_;
};


class segment_circle_intersect : public std::binary_function<point_t, point_t, bool>
{
public:
  segment_circle_intersect(const point_t& o, double r) : o_(o), rr_(r * r)
  {
  };

public:
  bool operator()(const point_t& p1, const point_t& p2) {
    vector_t p(p1 - o_), v(p2 - p1);

    double a = v * v;
    double b = v * p;
    double c = p * p - rr_;

    double d = b * b - a * c;

    if (d < 0)
      return false;
    
    d = sqrt(d);

    double t1 = (- b + d) / a;
    double t2 = (- b - d) / a;

    return ! (std::max(t1, t2) < -EPSILON || 1 + EPSILON < std::min(t1, t2));
  };

private:
  point_t o_;

  double rr_;
};


int main(int argc, char** argv)
{
  while (1) {
    int n, m;

    std::cin >> n;

    if (n == 0)
      break;
    
    std::vector<point_t> ws(n);
    std::vector<double>  rs(n);

    for (int i = 0; i < n; i ++)
      std::cin >> ws[i].x >> ws[i].y >> rs[i];

    std::cin >> m;

    for (int j = 0; j < m; j ++) {
      point_t t, s;

      std::cin >> t.x >> t.y >> s.x >> s.y;

      bool safe = false;

      for (int i = 0; i < n; i ++) {
        point_circle_intersect fn(ws[i], rs[i]);

        if (fn(t) && fn(s)) {
          ;
        }
        else if ((safe = segment_circle_intersect(ws[i], rs[i])(t, s))) {
          break;
        }
      }

      std::cout << (safe ? "Safe" : "Danger") << std::endl;
    }
  }

  return 0;
}