# Please tell me where I’m going wrong.

import fractions

import string

t=input()

if t>50 or t<1:

print “Not allowed”

exit()

while t>0:

n,a,k=raw_input().split()

n,a,k=[int(n),float(a),int(k)]

```
if n<3 or n>1000:
break
elif a<1.0 or a>1000000000.0:
break
elif k<1 or k>n:
break
ak=0.0
ak=a+(k-1)*((n-2)*(2*180)-2*a*n)/(n*(n-1))
b=fractions.Fraction(ak)
x=b.numerator
y=b.denominator
print x,y
t-=1
```