#include<iostream>
#include<cmath>
#include<cstdlib>

using namespace std;

int main() {
  int n;
  while(cin >> n, n != 0) {
    int m, wx[101], wy[101], wr[101];
    for(int i = 0; i < n; i++)  cin >> wx[i] >> wy[i] >> wr[i];
    cin >> m;
    while(m--) {
      int tx, ty, sx, sy, a, b, c, d;
      double e, len;
      cin >> tx >> ty >> sx >> sy;
      //|a*wx + b*wy + c| / √((a*a)+ (b*b)) = len
      a = (tx - sx);
      b = 0 - (ty - sy);
      c = 0 - (a * ty + b * tx);
      e = (double)sqrt(a * a + b * b);
      
      int cnt = 0;
      for(int i = 0; i < n; i++) {
	
	if( (d = b * wx[i] + a * wy[i] + c ) < 0) d = 0 - d; 
	len  = d / e;
	
	if(len > wr[i]) cnt = 1; //Danger交点0
	else if ((wx[i] - tx)*(wx[i] - sx) > 0 && (wy[i] - ty)*(wy[i] - sy) > 0) cnt = 1; //線分上じゃない時交点0
	else {//交点あり
	  double len_t = sqrt((tx - wx[i]) * (tx - wx[i]) + (ty - wy[i]) * (ty - wy[i])) , len_s = sqrt((sx - wx[i]) * (sx - wx[i]) + (sy - wy[i]) * (sy - wy[i]));
	  if(!((len_t < wr[i] && len_s < wr[i]))){ cnt = 2; break; } //鬼, 自分どちらかが囲まれているならSafe
	}
      }
      if (cnt  == 2 || cnt == 0) cout << "Safe" << endl;
      else if( cnt == 1 ) cout << "Danger" << endl;
    }
  }
  return 0;
}