#include <bits/stdc++.h>
using namespace std;
struct P {
  double x, y;
  P(double X, double Y) {
    x = X;
    y = Y;
  }
  P rotate(double theta) {
    return P(y * cos(theta) - x * sin(theta), y * sin(theta) + x * cos(theta));
  }
  bool operator<(const P &B) const { return x == B.x ? y < B.y : x < B.x; }
};
struct Line {
  double a, b, c;
  Line(double A, double B, double C) {
    a = A;
    b = B;
    c = C;
  }
  Line(double x_1, double y_1, double x_2, double y_2) {
    a = y_1 - y_2;
    b = x_2 - x_1;
    c = y_1 * (x_1 - x_2) - x_1 * (y_1 - y_2);
  }
  double x(double y) { return -(double)(b * y + c) / a; }
  double y(double x) { return -(double)(a * x + c) / b; }
};
int solve() {
  int n, m;
  int wx[1010], wy[1010], r[1010];
  const double eps = 1e-10;
  scanf("%d", &n);
  if (n == 0) return false;
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", wx + i, wy + i, r + i);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int tx, ty, sx, sy;
    bool flag = false;
    scanf("%d%d%d%d", &tx, &ty, &sx, &sy);
    Line l(tx, ty, sx, sy);
    for (int j = 0; j < n; j++) {
      double dist =
          abs(l.a * wx[j] + l.b * wy[j] + l.c) / sqrt(l.a * l.a + l.b * l.b);
      int dist1 = (wx[j] - tx) * (wx[j] - tx) + (wy[j] - ty) * (wy[j] - ty);
      int dist2 = (wx[j] - sx) * (wx[j] - sx) + (wy[j] - sy) * (wy[j] - sy);
      if (dist1 <= r[j] * r[j] && dist2 <= r[j] * r[j]) continue;
      if (dist > r[j] + eps) continue;
      double a = -1 / l.a;
      double b = wy[j] - a * wx[j];
      double cx = (-l.c - b * l.b) / (l.a + a * l.b);
      if (min(tx, sx) <= cx + eps && cx - eps <= max(tx, sx)) {
        flag = true;
      } else {
        if (dist1 <= r[j] * r[j] || dist2 <= r[j] * r[j]) {
          flag = true;
        }
      }
    }
    if (flag)
      puts("Safe");
    else
      puts("Danger");
  }
  return true;
}
int main() {
  while (solve())
    ;
}
