12351: 计算天数

Memory Limit:32 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:4 Solved:0

Description

输入年月日,计算该填是本年的第几天。例如1990 20 日是1990 年的第263 天,

2000 日是2000 年第122 天。(闰年:能被400 正除,或能被整除但不能被100

整除。每年1357810 为大月)

Input

输入第一行为样例数m,接下来m行每行3个整数分别表示年月日。

Output

输出m行分别表示题目所求。

Sample Input Copy

2
1990 9 20
2000 5 1

Sample Output Copy

263
122

HINT

闰年:能被400 正除,或能被4 整除但不能被100整除。每年1、3、5、7、8、10 为大月