#1934 Maximum in the Cycle of 1

5 s   128 MB  

Description

문제 링크 (pdf)

Sample Input

Sample Output

4
1 4 1
2 7 3
3 10 5
4 20 7
1 6
2 168
3 86400
4 11585247657984000

Source

2011 ACM-ICPC Greater New York Region