Chef is making polygon cakes in his kitchen today! 
Since the judge panel is very strict, Chef's cakes must be beautiful and have sharp and precise $internal$ angles in arithmetic progression. 
Given the number of sides, $N$, of the cake Chef is baking today and also the measure of its first angle(smallest angle), $A$, find the measure of the $K^{th}$ angle.

-----Input:-----
- The first line contains a single integer $T$, the number of test cases. 
- The next $T$ lines contain three space separated integers $N$, $A$ and $K$, the number of sides of polygon, the first angle and the $K^{th}$ angle respectively. 

-----Output:-----
For each test case, print two space separated integers $X$ and $Y$, such that the $K^{th}$ angle can be written in the form of $X/Y$ and $gcd(X, Y) = 1$

-----Constraints-----
- $1 \leq T \leq 50$
- $3 \leq N \leq 1000$
- $1 \leq A \leq 1000000000$
- $1 \leq K \leq N$
- It is guaranteed the answer is always valid.

-----Sample Input:-----
1
3 30 2

-----Sample Output:-----
60 1

Starter code:

Solutions:
# cook your dish here
import math
T = int(input())
for _ in range(T):
 N, A, K = map(int, input().split(" "))
 total = (N-2) * 180
 diffT = total - N*A
 diffN = sum(range(1,N))
 r = (A*diffN+(K-1)*diffT)
 
 d = math.gcd(r, diffN)
 while d > 1:
  r//=d
  diffN//=d
  d = math.gcd(r, diffN)
 print(r, diffN)

# cook your dish here
import math
T = int(input())
for _ in range(T):
 N, A, K = list(map(int, input().split(" ")))
 total = (N-2) * 180
 
 # 360 = 60 + (1+2+3)*diff + 3*60
 # 360 = 240 + 6*diff
 # 120 = 6*diff
 # 120 / 6 = diff
 
 # K: 60 + (K-1) * diffT / diffN = (60*diffN+(K-1)*diffT) / diffN
 
 diffT = total - N*A
 diffN = sum(range(1,N))
 r = (A*diffN+(K-1)*diffT)
 
 d = math.gcd(r, diffN)
 while d > 1:
  r//=d
  diffN//=d
  d = math.gcd(r, diffN)
 print(r, diffN)


def hcfnaive(a,b): 
 if(b==0): 
  return a 
 else: 
  return hcfnaive(b,a%b)
 
for i in range(int(input())):
 (N,A,K)=map(int,input().split())
 s=180*(N-2)
 d=hcfnaive(A*N*(N-1)+(s-N*A)*2*(K-1),N*(N-1))
 print((A*N*(N-1)+(s-N*A)*2*(K-1))//d,(N*(N-1))//d)

# cook your dish here
import math
T = int(input())
for _ in range(T):
 N, A, K = list(map(int, input().split(" ")))
 total = (N-2) * 180
 
 # 360 = 60 + (1+2+3)*diff + 3*60
 # 360 = 240 + 6*diff
 # 120 = 6*diff
 # 120 / 6 = diff
 
 # K: 60 + (K-1) * diffT / diffN = (60*diffN+(K-1)*diffT) / diffN
 
 diffT = total - N*A
 diffN = sum(range(1,N))
 r = (A*diffN+(K-1)*diffT)
 
 d = math.gcd(r, diffN)
 while d > 1:
  r//=d
  diffN//=d
  d = math.gcd(r, diffN)
 print(r, diffN)


# cook your dish here

def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here

def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

def gcd(a,b):
 if b==0:
  return a
 return gcd(b,a%b)
t=int(input())
for i in range(t):
 temp=input().split()
 n=int(temp[0])
 a=int(temp[1])
 k=int(temp[2])
 #(n/2)(2a+(n-1)d)=(n-2)180
 tempn=(n-2)*180
 tempn=tempn*2
 tempd=n
 tempn=tempn-2*a*tempd
 tempd=tempd*(n-1)
 tempn=tempn*(k-1)+a*tempd
 g=gcd(tempn,tempd)
 tempn/=g
 tempd/=g
 print(int(tempn),int(tempd)) 

def gcd(A, B):
 if B==0:
  return A;
 else:
  return gcd(B,A%B);


t = int(input())

for _ in range(t):
 n,a,k = list(map(int, input().split()))
 #d = /(n*(n-1))
 num = a*(n*(n-1)) + (k-1)*(360*(n-2)-2*a*n)
 den = n*(n-1)
 print(f"{num//gcd(num, den)} {den//gcd(num, den)}")
 


def gcd(A, B):
 if B==0:
  return A;
 else:
  return gcd(B,A%B);


t = int(input())

for _ in range(t):
 n,a,k = list(map(int, input().split()))
 #d = /(n*(n-1))
 num = a*(n*(n-1)) + (k-1)*(360*(n-2)-2*a*n)
 den = n*(n-1)
 print(f"{num//gcd(num, den)} {den//gcd(num, den)}")
 


# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here
# cook your dish here
# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here
# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

# cook your dish here
def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k
 s=s//k
 print(d+s*a,s)

def gcd(d,s):
 if s==0:
  return d
 else:
  return gcd(s,d%s)
for _ in range(int(input())):
 n,a,k=[int(x) for x in input().split()]
 d = (360*(n-2)-2*a*n)*(k-1)
 s = n*(n-1)
 k = gcd(d,s)
 d = d//k 
 s=s//k
 print(d+s*a,s)

from fractions import Fraction
for i in range(int(input())):
 a = [int(x) for x in input().split()]
 n=a[0]
 A=a[1]
 k=a[2]
 q=A+((k-1)/(n-1))*(360*(n-2)/n -2*A)
 x=1
 if q-int(q)<1 and q-int(q)>0:
  o=Fraction(q).limit_denominator()
  print(o.numerator,o.denominator)
 else:
  print(int(q),1)

import math
t=int(input())
while(t!=0):
 t-=1
 n,a,k=list(map(int,input().split()))
 g=n*(n-1)
 d=(360*(n-2)-2*a*n)
 f=(a*g+(k-1)*d)
 j=math.gcd(f,g)
 b=f//j
 e=g//j
 print(b,e)