题目描述
Mo the pro does not want to be late for the promo of Incident'14, the annual cultural fest of NITK. In his excitement, he drops his only 2 wrist watches. He sets his watches according to a wall clock. After some time N he discovers that one of the watch is X minutes fast, and the other watch is Y minutes slow. What is the minimum time(in minutes) after which both the watches show the same time ?
Input
The first line of the input is T the number of test cases. Each line of the test case contains 3 integers N,X,Y.
Output
Output the smallest time in minutes(output the integer only) after which the 2 watches will show the same time.
Constraints
1 ≤ T ≤ 100
0 < N ≤ 1440
0 ≤ X,Y ≤ 60
Example
Input:
2
10 5 5
1 1 1
Output:
720
360
输入格式
见题面
输出格式
见题面