CodeEff/ECCO huggingface dataset:
# Original solution
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N=int(eval(input()))
from collections import defaultdict
dic=defaultdict(int)
for i in range(1,N+1):
  arr=factorization(i)
  for a in arr:
    dic[a[0]]+=a[1]
    
# これら素因数の集まりに対して、
# 2,4,4
# 74
# 2,24
# 4,14
# 個選択できるペアをいくつ作れるかを数える
items=list(dic.items())

def c(items,p):
  return len(list([x for x in items if x[1]>=p]))

ans=0
ans+=c(items,74)
ans+=(c(items,4)*(c(items,4)-1)*(c(items,2)-2))//2
ans+=c(items,24)*(c(items,2)-1)
ans+=c(items,14)*(c(items,4)-1)
print(ans)

# Optimized solution
# 約数の数 = 素因数分解して、各素因数の(指数 + 1)をかけ合わせたもの
# 例：12 = 2^2 * 3^1 -> 3 * 2 = 6 (1,2,3,4,6,12)
# これが75になるためには、以下のペアを作れる必要がある。この組み合わせを数える
# 75 : 指数が74
# 3 * 25 : 指数が2 , 24
# 5 * 15 : 指数が4 , 14
# 3 * 5 * 5 : 指数が2,4,4

import sys
readline = sys.stdin.readline

N = int(readline())

def factorization(n):
  res = []
  temp = n
  for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
    if temp % i == 0:
      cnt = 0
      while temp % i == 0:
        cnt += 1
        temp //= i
      res.append([i,cnt])
  if temp != 1:
    res.append([temp, 1])
  if res == []:
    res.append([n, 1])
  return res

from collections import defaultdict
dic = defaultdict(int)
for i in range(1, N + 1):
  res = factorization(i)
  for r in res:
    dic[r[0]] += r[1]

ans = 0

vals = list(dic.values())
# 74以上のものを探す
i74 = 0
for v in vals:
  if v >= 74:
    i74 += 1
ans += i74

i2 = 0
i24 = 0
# 2,24以上のものを探す
for v in vals:
  if v >= 24:
    i24 += 1
  elif v >= 2:
    i2 += 1
ans += (i24 * (i24 - 1))
ans += i24 * i2
  
# 5,15以上のものを探す
i4 = 0
i14 = 0
for v in vals:
  if v >= 14:
    i14 += 1
  elif v >= 4:
    i4 += 1
ans += (i14 * (i14 - 1))
ans += i14 * i4

# 2,4,4を探す
i4 = 0
i2 = 0
for v in vals:
  if v >= 4:
    i4 += 1
  elif v >= 2:
    i2 += 1
if i4 >= 3:
  ans += ((i4 * (i4 - 1)) // 2) * (i4 - 2)
ans += ((i4 * (i4 - 1)) // 2) * i2

print(ans)
# Original solution
n = int(eval(input()))
e = [0] * (n+1)

for i in range(2, n+1):
    for j in range(2, i+1):
        while i % j == 0:
            e[j] += 1
            i //= j
            
def count(m):
    return len(list([x for x in e if x >= m-1]))

a = count(75)
b = count(25) * (count(3) - 1)
c = count(15) * (count(5) - 1)
d = count(5) * (count(5) - 1) * (count(3) - 2) // 2

print((a + b + c + d))

# Optimized solution
n = int(eval(input()))

def nprf(m):
    pf = {}
    for i in range(2, m + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                pf[j] = pf.get(j, 0) + 1
                i //= j
    return pf

def c(P, m):
    count = 0
    for i in P:
        if P[i] >= m - 1:
            count += 1
    return count   
    
P = nprf(n)

f75 = c(P, 75)
f253 = c(P, 25) * (c(P, 3) - 1)
f155 = c(P, 15) * (c(P, 5) - 1)
f553 = int(c(P, 5) * (c(P, 5) - 1) * (c(P, 3) - 2) * 0.5)

print((f75 + f253 + f155 + f553))
# Original solution
# 因数を昇順に全列挙
from collections import Counter
import math
def com(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
fac_list = []
def factoring(n):
    for i in range(2,n+1):
        if n % i == 0:
            fac_list.append(i)
            n = n // i
            break
    if n == 1:
        return fac_list
    else:
        return factoring(n)
# (素因数,指数)
n = int(eval(input()))
c = list(Counter(factoring(math.factorial(n))).values())
# 指数 (2,4,4),(2,24),(4,14),(74) の場合の数
l = [0]*5 # [2,4,14,24,74]
for e in c:
    if e >= 74:
        index = 4
    elif e >= 24:
        index = 3
    elif e >= 14:
        index = 2
    elif e >= 4:
        index = 1
    elif e >= 2:
        index = 0
    else:
        continue
    l[index] += 1
sum_l = sum(l)
num_74 = l[4]
if sum_l - l[0] - 1 > 0:
    num_4_14 = (l[2] + l[3] + l[4])*(sum_l - l[0] - 1)
else:
    num_4_14 = 0
if sum_l - 1 > 0:
    num_2_24 = (l[3] + l[4])*(sum_l - 1)
else:
    num_2_24 = 0
if sum_l - l[0] >= 2:
    num_2_4_4 = com(sum_l-l[0],2)*(sum_l - 2)
else:
    num_2_4_4 = 0
ans = num_74 + num_4_14 + num_2_24 + num_2_4_4
print(ans)

# Optimized solution
def factoring(n):
    for i in range(2, n+1):
        while n % i == 0:
            n //= i
            d[i] += 1

N = int(eval(input()))

d = [0]*(N+1)

for n in range(2,N+1):
    factoring(n)

def num(n):
    return len([e for e in d if e >= n])

ans = num(74) + num(14)*(num(4)-1) + num(24)*(num(2)-1) + num(4)*(num(4)-1)*(num(2)-2)//2
print(ans)
# Original solution
d={"o":1,"x":-1}
N=int(input())
s=input()
s+=s[0]
def ans(a):
    for i in range(1,N+1):
        a=a+[a[i]*a[i-1]*d[s[i]]]
    if a[:2]==a[-2:]:
        return a[:-2]
    else:
        return []
for ini in [[1,1],[1,-1],[-1,1],[-1,-1]]:
    a=ans(ini)
    if a:
        print("".join(['S' if x>0 else 'W' for x in a]))
        break
else:
    print("-1")

# Optimized solution
d={"o":1,"x":-1}
w={"S":1,"W":-1}
n={1:"S",-1:"W"}
N=int(input())
s=input()
s+=s[0]
def ans(a):
    for i in range(1,N+1):
        a+=n[w[a[i]]*w[a[i-1]]*d[s[i]]]
    if a[:2]==a[-2:]:
        return a[:-2]
    else:
        return []
for ini in ["SS","SW","WS","WW"]:
    a=ans(ini)
    if a:
        print(a)
        break
else:
    print("-1")
# Original solution
a, b = list(map(str, input().split()))
c = int(a + b)

for i in range(c):
    if i**2 == c:
        ans = 'Yes'
        break
    else:
        ans = 'No'

print(ans)

# Optimized solution
a, b = list(map(str, input().split()))
c = int(a + b)

for i in range(4, 317):
    if i**2 == c:
        ans = 'Yes'
        break
    else:
        ans = 'No'

print(ans)
# Original solution
# coding: utf-8
import sys
input = sys.stdin.readline

N = int(input().replace(" ", ""))
print(("Yes" if N**0.5 == int(N**0.5) else "No"))


# Optimized solution
# coding: utf-8
import sys
input = sys.stdin.readline

N = int(input().replace(" ", ""))
print(("Yes" if (N**0.5).is_integer() else "No"))
# Original solution
import sys
import math

A,B=input().split()
X=int(A+B)

print(('Yes' if math.sqrt(X).is_integer() else 'No'))

# Optimized solution
import sys
 
A,B=input().split()
X=int(A+B)
L=[x*x for x in range(1,1001)]
 
if X in L:
  print('Yes')
else:
  print('No')
# Original solution
a,b = list(map(str,input().split()))
x = int(a + b)
ans = "No"
for i in range(x // 2):
    if x == i * i:
        ans = "Yes"
print(ans)

# Optimized solution
a,b = list(map(str,input().split()))
x = int(a + b)
if x ** 0.5 == int(x ** 0.5):
    print("Yes")
else:
    print("No")
# Original solution
a, b = input().split()
n = int(a + b)

flag = False
for i in range(n):
    if i ** 2 == n:
        flag = True
        break

print(('Yes' if flag else 'No'))


# Optimized solution
a, b = input().split()
n = int(a + b)

flag = False
for i in range(1000):
    if i ** 2 == n:
        flag = True
        break

print(('Yes' if flag else 'No'))
# Original solution
a,b = input().split()
t = int(a+b)
flag = False
for i in range(t//2 + 1):
    if i**2 == t:
        flag = True
        break
if flag: print("Yes")
else: print("No")


# Optimized solution
a,b = input().split()
t = int(a+b)
print(("Yes" if t == int(t**0.5)**2 else "No"))
# Original solution
a,b=input().split()
num=int(a+b)
for i in range(num):
    if i*i == num:
        print('Yes')
        break
else:
    print('No')

# Optimized solution
a,b=input().split()
x=int(a+b)
for i in range(int(x**0.5)+1):
    if i**2 ==x:
        print('Yes')
        exit()
print('No')
# Original solution
a,b = input().split()
x = 4
ab = int(a+b)
while x*x < ab:
    x += 1
print(("Yes" if x*x == ab else "No"))

# Optimized solution
a,b = input().split()
ab = int(a+b)
x = int(ab**0.5)
print(("Yes" if x**2==ab else "No"))
# Original solution
_in =input().split()

#_in = ["10", "21"]
#文字の結合
cont_str = _in[0] + _in[1]

#数字に変換
cont_num = int(cont_str)


#平方数の判定
#総当たり頭悪そう　1<= ab <= 100 なので 4*4~ 100*100
sqrt_flag = False
for i in range(4, 1000):
        sqrt = i * i
        #print(sqrt)
        if cont_num == sqrt:
            sqrt_flag = True
            break
if sqrt_flag:
    print('Yes')
else:
    print('No')

# Optimized solution
#入力値の取得
_in =input().split()

#_in = ["10", "21"]
#文字の結合
cont_str = _in[0] + _in[1]

#数字に変換
cont_num = int(cont_str)


#平方数の判定
#総当たり頭悪そう　1<= ab <= 100 なので 4*4~ 100*100
sqrt_flag = False
for i in range(4, 500):
        sqrt = i * i
        #print(sqrt)
        if cont_num == sqrt:
            sqrt_flag = True
            break
if sqrt_flag:
    print('Yes')
else:
    print('No')
# Original solution
a, b = list(map(int,input().split()))
ab = int(str(a) + str(b))
abroot = str(ab**0.5)
if abroot.split(".")[1:][0] == "0":
    print("Yes")
else:
    print("No")

# Optimized solution
a, b = list(map(int,input().split()))
if str(int(str(a) + str(b))**0.5).split(".")[1:][0] == "0":
    print("Yes")
else:
    print("No")
# Original solution
from sys import stdin


def main() -> None:
    a = next_int()
    b = next_int()

    ab = int(str(a) + str(b))
    sqrt = int(ab ** 0.5)

    print((["No","Yes"][sqrt ** 2 == ab]))


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

# Optimized solution
from sys import stdin


def main() -> None:
    a = next_int()
    b = next_int()

    ab = int(str(a) + str(b))
    sqrt = int(ab ** 0.5)

    print((["No", "Yes"][int(sqrt ** 2 == ab)]))


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()
# Original solution
import math
a, b = input().split()
num = int(a + b)
li = []
for i in range(1000):
    li.append(i ** 2)
if (num in li):
    print('Yes')
else:
    print('No')

# Optimized solution
import sys
import math
a, b = input().split()
num = int(a + b)
rli = [0]
for i in range(400):
    rli.append(i ** 2)
if (num in rli):
    print('Yes')
else:
    print('No')
# Original solution
a = input().replace(' ','')
if int(a)**0.5 % 1 == 0:
    print('Yes')
else:
    print('No')


# Optimized solution
a = input().replace(' ','')
print(('Yes' if int(a)**0.5 % 1 == 0 else 'No'))
# Original solution
import math

a, b = input().split()
n = int(a+b)

m = int(math.sqrt(n))

if abs(m**2 - n) < 1e-6:
    print("Yes")
else:
    print("No")

# Optimized solution
a, b = input().split()
N = int(a+b)
if N == int(N**(0.5))**2:
    print('Yes')
else:
    print('No')
# Original solution
a, b = input().split()
c = int(a + b)
print(("Yes" if c ** 0.5 % 1 == 0 else "No"))


# Optimized solution
a, b = list(map(str, input().split()))
c = int(a + b)
if c ** 0.5 == int(c ** 0.5):
    print("Yes")
else:
    print("No")
# Original solution
a,b=input().split()
z=int(a+b)
print(("Yes" if z**.5==int(z**.5) else "No"))

# Optimized solution
print(("No" if int(input().replace(" ",""))**.5%1 else "Yes"))
# Original solution
a, b = input().split()
target = a + b

heihousuu = [i ** 2 for i in range(1000) if i ** 2 <= 100100]

if int(target) in heihousuu:
    print('Yes')
else:
    print('No')

# Optimized solution
a, b = input().split()


ab = int(a + b)

if (ab ** 0.5).is_integer():
    print("Yes")
else:
    print("No")
# Original solution
import math
a,b = input().split()
S = a+b
K = int(S)
if math.sqrt(K) %1 == 0:
  print("Yes")
else:
  print("No")

# Optimized solution
import math
s,t = input().split()
N = int(s+t)
if (N**0.5)%1 == 0:
    print("Yes")
else:
    print("No")
# Original solution
import math

def solve():
    a,b = input().split()
    num = int(a+b)
    if math.sqrt(num).is_integer():
        print('Yes')
    else:
        print('No')
        
solve()

# Optimized solution
def solve():
    a,b = input().split()
    num = int(a+b)
    for i in range(1,1000):
        if i**2 == num:
            print('Yes')
            return
    
    print('No')
    
solve()
# Original solution
a,b = input().split()
ab = a+b
for i in range(int(a+b)):
    if int(a+b) == i**2:
        print("Yes")
        exit()
print("No")

# Optimized solution
from math  import sqrt 
a,b = input().split()
ab = int(a+b)
print((["No","Yes"][int(sqrt(ab))**2 == ab]))
# Original solution
x = int(input().replace(' ', ''))
for i in range(x):
    if i*i == x:
        print('Yes')
        exit()
print('No')

# Optimized solution
x = int(input().replace(' ', ''))
print(('Yes' if x in [i*i for i in range(1000)] else 'No'))
# Original solution
a,b=list(map(str,input().split()))
c=int(a+b)
sq = [i*i for i in range(1,10001)]
if c in sq: print('Yes')
else: print('No')

# Optimized solution
a, b = map(int, input().split())

c = int(str(a) + str(b))

square = [i ** 2 for i in range(1, 500)]

print('Yes') if c in square else print('No')
# Original solution
import math
a,b= input().split()

gosei = int(a+b)

tekito = math.ceil(gosei)

r = 'No'
for i in range(1,tekito+1):
  if gosei % i == 0 and i == gosei // i:
    r = 'Yes'
    break
print(r)
  

# Optimized solution
import math
a,b= input().split()
gosei = int(a+b)
tekito = math.ceil(math.sqrt(100100))
r = 'No'
for i in range(1,tekito+1):
  if i**2 == gosei:
    r = 'Yes'
    break
print(r)
# Original solution
a,b=input().split()
c=a+b
c=int(c)
if any(i**2 == c for i in range(c//2)):
  print("Yes")
else:
  print("No")

# Optimized solution
a,b=input().split()
c=a+b
c=int(c)
if (c ** .5).is_integer():
  print("Yes")
else:
  print("No")
# Original solution
a,b = list(map(str,input().split()))

for i in range(1,10001):
    if i**2 == int(a+b):
        print('Yes')
        exit()
        
print('No')

# Optimized solution
a,b = list(map(str,input().split()))

N = int(a+b)

import sys

for i in range(1,int(N**0.5)+1):
    if i**2 == N:
        print('Yes')
        sys.exit()
        
print('No')
# Original solution
a, b = list(map(str, input().split()))
if int(int(a + b) ** 0.5) == int(a + b) ** 0.5:
    print("Yes")
else:
    print("No")


# Optimized solution
a = int("".join(list(input().split())))
if a ** 0.5 == int(a ** 0.5):
    print("Yes")
else:
    print("No")
# Original solution
a = list(input().split())
b = int(a[0]+a[1])

if b==int(b**0.5)**2:
  print("Yes")
else:
  print("No")

# Optimized solution
a,b = list(input().split())
n = int(a+b)

if n==int(n**0.5)**2:
  print("Yes")
else:
  print("No")
# Original solution
x = int(input().replace(' ',''))
y = int(x**0.5)
print(('Yes' if y*y==x else 'No'))

# Optimized solution
a = int(input().replace(' ',''))
s = int(a**0.5)
print(('Yes' if s*s == a else 'No'))
# Original solution
a, b = input().split()

x = int(a+b)

if str(x ** (0.5))[-1] == "0":
  print("Yes")
else:
  print("No")

# Optimized solution
a, b = input().split()
x = int(a+b)
if str(x**0.5)[-1] == '0':
    print("Yes")
else:
    print("No")
# Original solution
a,b=list(map(int,input().split()))
for i in range (1,100100):
  if 1<=b<=9:
    if 10*a+b==i**2:
      print('Yes')
      exit()
  if 10<=b<=99:
    if 100*a+b==i**2:
      print('Yes')
      exit()
  if b==100:
    if 1000*a+b==i**2:
      print('Yes')
      exit()
print('No')

    

# Optimized solution
a,b=input().split()
c=a+b
for i in range(1,1000):
  if int(c)==i**2:
    print('Yes')
    exit()
print('No')
# Original solution
import math
a,b = input().split()
print(('Yes' if math.sqrt(int(a+b)) == int(math.sqrt(int(a+b))) else 'No'))

# Optimized solution
a,b = input().split()
n = int(a+b)
print(('Yes' if n**0.5 == int(n**0.5) else 'No'))
# Original solution
import math

ab = int(input().replace(' ', ''))

r = round(math.sqrt(ab))
print(('Yes' if r**2 == ab else 'No'))


# Optimized solution
import math

ab = int(input().replace(' ', ''))

print(('Yes' if math.sqrt(ab).is_integer() else 'No'))
# Original solution
a, b = input().split()
num = int(a + b) ** (1/2)
if(num == int(num)):
  print("Yes")
else:
  print("No")

# Optimized solution
a, b = input().split()
num = int(a + b) ** 0.5
if(num == int(num)):
  print("Yes")
else:
  print("No")
# Original solution
a, b = input().split()
num = int(a + b) ** 0.5
if(num == int(num)):
  print("Yes")
else:
  print("No")

# Optimized solution
a, b = input().split()
x = int(a+b)**0.5
ans = "No"
if(x == int(x)):
  ans = "Yes"
print(ans)
# Original solution
a,b = list(map(str,input().split( )))
#print(a+b)
count=0
for i in range(1,int(a+b)):
  if(i*i == int(a+b)):
    print('Yes')
    count+=1
    break
if(count==0):print('No')

# Optimized solution
print(("No"if int("".join(input().split()))**.5%1 else"Yes"))
# Original solution
import math
A,B = input().split()
Num = int(A+B)
SqN = math.sqrt(Num)
Flag = False
for T in range(math.floor(SqN),math.ceil(SqN)+1):
    if T*T==Num:
        Flag = True
        break
if Flag:
    print('Yes')
else:
    print('No')

# Optimized solution
import math
A,B = input().split()
Num = int(A+B)
SqN = math.sqrt(Num)
if math.floor(SqN)**2==Num or math.ceil(SqN)**2==Num:
    print('Yes')
else:
    print('No')
# Original solution
def resolve():
    import math
    a, b = input().split()
    num = int(a+b)
    ans = (num**0.5)%1
    if ans == 0:
        print('Yes')
    else:
        print('No')
resolve()

# Optimized solution
def resolve():
    a, b = input().split()
    num = int(a+b)
    ans = (num**0.5)%1
    if ans == 0:
        print('Yes')
    else:
        print('No')
resolve()
# Original solution
def dist(x,y,x1,y1):
	return (x-x1)**2+(y-y1)**2
	
def inWall(x,y,x1,y1,r):
 	return True if dist(x,y,x1,y1) <= (r + 1e-9)**2 else False

def isHide(x,y,r,a,b,c):
	D = abs(a*x+b*y+c)/(a**2+b**2)**0.5
	return True if D <= r + 1e-9 else False

def isBetween(x,y,tx,ty,sx,sy):
	a,b,c = dist(x,y,tx,ty),dist(x,y,sx,sy),dist(tx,ty,sx,sy)
	if c > b and c > a: return True
	a,b,c = sorted([a,b,c])
	return True if c-a-b <= 0 else False

while 1:
	n = eval(input())
	if n == 0: break
	wall = [list(map(int,input().split())) for i in range(n)]
	for i in range(eval(input())):
		tx,ty,sx,sy = list(map(int,input().split()))
		a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx
		for x,y,r in wall:
			t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r)
			if t_in != s_in or (not t_in and isBetween(x,y,tx,ty,sx,sy) and isHide(x,y,r,a,b,c)):
				print("Safe")
				break
		else:
			print("Danger")

# Optimized solution
def inWall(x,y,x1,y1,r):
	return True if ((x-x1)**2+(y-y1)**2)**0.5 <= r + 1e-9 else False

def isHide(x,y,r,a,b,c):
	D = abs(a*x+b*y+c)/(a**2+b**2)**0.5
	return True if D <= r + 1e-9 else False

def isBetween(x,y,tx,ty,sx,sy):
	a,b,c = (x-tx)**2+(y-ty)**2,(x-sx)**2+(y-sy)**2,(sx-tx)**2+(sy-ty)**2
	if c > b and c > a: return True
	a,b,c = sorted([a,b,c])
	return True if c-a-b <= 0 else False

while 1:
	n = eval(input())
	if n == 0: break
	wall = [list(map(int,input().split())) for i in range(n)]
	for i in range(eval(input())):
		tx,ty,sx,sy = list(map(int,input().split()))
		a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx
		for x,y,r in wall:
			t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r)
			if t_in != s_in or (not t_in and isBetween(x,y,tx,ty,sx,sy) and isHide(x,y,r,a,b,c)):
				print("Safe")
				break
		else:
			print("Danger")
# Original solution
def inWall(x,y,x1,y1,r):
	return True if ((x-x1)**2+(y-y1)**2)**0.5 <= r + 1e-9 else False

def isHide(x,y,r,a,b,c):
	D = abs(a*x+b*y+c)/(a**2+b**2)**0.5
	return True if D <= r + 1e-9 else False

def isBetween(x,y,tx,ty,sx,sy):
	a,b,c = (x-tx)**2+(y-ty)**2,(x-sx)**2+(y-sy)**2,(sx-tx)**2+(sy-ty)**2
	if c > b and c > a: return True
	a,b,c = sorted([a,b,c])
	return True if c-a-b <= 0 else False

while 1:
	n = eval(input())
	if n == 0: break
	wall = [list(map(int,input().split())) for i in range(n)]
	for i in range(eval(input())):
		tx,ty,sx,sy = list(map(int,input().split()))
		a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx
		for x,y,r in wall:
			t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r)
			if t_in != s_in or (not t_in and isBetween(x,y,tx,ty,sx,sy) and isHide(x,y,r,a,b,c)):
				print("Safe")
				break
		else:
			print("Danger")

# Optimized solution
def inWall(x,y,x1,y1,r):
	return True if ((x-x1)**2+(y-y1)**2)**0.5 <= r + 1e-9 else False

def isHide(x,y,r,a,b,c):
	D = abs(a*x+b*y+c)/(a**2+b**2)**0.5
	return True if D <= r + 1e-9 else False

def isBetween(x,y,tx,ty,sx,sy):
	a,b,c = (x-tx)**2+(y-ty)**2,(x-sx)**2+(y-sy)**2,(sx-tx)**2+(sy-ty)**2
	if c > b and c > a: return True
	a,b,c = sorted([a,b,c])
	return True if c-a-b <= 0 else False

while 1:
	n = eval(input())
	if n == 0: break
	wall = [list(map(int,input().split())) for i in range(n)]
	for i in range(eval(input())):
		tx,ty,sx,sy = list(map(int,input().split()))
		a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx
		for x,y,r in wall:
			t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r)
			if t_in != s_in or (not t_in and isHide(x,y,r,a,b,c) and isBetween(x,y,tx,ty,sx,sy)):
				print("Safe")
				break
		else:
			print("Danger")
# Original solution
import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [list(map(int,input().split())) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    st=[tx-sx,ty-sy]; rst=R(st)
    F=[rwt<r,rsw<r]
    if rst==0: c=1
    elif F==[1,1]: c=1
    elif F==[1,0] or F==[0,1]: c=0
    elif F==[0,0]:
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4))
      if C(a,b) and C(rst**2,rsw**2-r**2): c=0
      else: c=1
    if c==0: return 0
    x.append(c)
  return all(x)

while 1:
  n=eval(input())
  if n==0: break
  WP=I(n)
  P=I(eval(input()))
  for e in P: print(["Safe","Danger"][f(e)])

# Optimized solution
import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [list(map(int,input().split())) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  st=[tx-sx,ty-sy]; rst=R(st)
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    F=[rwt<r,rsw<r]
    c=1
    if F==[1,0] or F==[0,1]: return 0
    elif F==[0,0]:
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4))
      if C(a,b) and C(rst**2,rsw**2-r**2): return 0
    x.append(c)
  return all(x)

while 1:
  n=eval(input())
  if n==0: break
  WP=I(n)
  P=I(eval(input()))
  for e in P: print(["Safe","Danger"][f(e)])
# Original solution
for roop in range(int(input())):
    h,m = list(map(int,input().split(":")))
    s = 120*h + 2*m
    l = 24*m
    if l < s: l,s = s,l
    arg = l - s if l - s < 180*4 else 360*4-(l-s)
    if   arg < 30*4: print("alert")
    elif arg < 90*4: print("warning")
    else           : print("safe")

# Optimized solution
for roop in range(int(input())):
    h,m = list(map(int,input().split(":")))
    s = 60*h + m
    l = 12*m
    if l < s: l,s = s,l
    arg = l - s if l - s < 180*2 else 360*2-(l-s)
    if   arg < 30*2: print("alert")
    elif arg < 90*2: print("warning")
    else           : print("safe")
# Original solution
#!/usr/bin/env python3

while(True):
	try:
		a,b=list(map(int, input().split()))
	except EOFError:
		break
	gcd=1
	for i in range(1, a):
		if(a%i==0 and b%i==0):
			gcd=i
	lcm=int(a*b/gcd)
	print(("{0} {1}".format(gcd, lcm)))

# Optimized solution
#!/usr/bin/env python3

while(True):
	try:
		a,b=list(map(int, input().split()))
	except EOFError:
		break

	#euclidian algorithm	
	r=a%b
	x,y=a,b
	while(r>0):
		x=y
		y=r
		r=x%y
	gcd=y
	lcm=int(a*b/gcd)
	print(("{0} {1}".format(gcd, lcm)))