eolymp
bolt
Try our new interface for solving problems
Problems

Millennium

Millennium

A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day \textbf{1} of the month \textbf{1} of the year \textbf{1}. Each year consists of \textbf{10} months, from month \textbf{1} through month \textbf{10}, and starts from a \textit{big month}. A common year shall start with a big month, followed by \textit{small months} and big months one after another. Therefore the first month is a big month, the second month is a small month, the third a big month, ..., and the \textbf{10}^th and last month a small one. A big month consists of \textbf{20} days and a small month consists of \textbf{19} days. However years which are multiples of three, that are year \textbf{3}, year \textbf{6}, year \textbf{9}, and so on, shall consist of \textbf{10} big months and no small month." Many years have passed since the calendar started to be used. For celebration of the millennium day (the year \textbf{1000}, month \textbf{1}, day \textbf{1}), a royal lottery is going to be organized to send gifts to those who have lived as many days as the number chosen by the lottery. Write a program that helps people calculate the number of days since their birthdate to the millennium day. \InputFile The input is formatted as follows. \textbf{nY_1 M_1 D_1Y_2 M_2 D_2...Y_n M_n D_n} Here, the first line gives the number of datasets as a positive integer \textit{\textbf{n}}, which is less than or equal to \textbf{100}. It is followed by \textit{\textbf{n}} datasets. Each dataset is formatted in a line and gives three positive integers, \textit{\textbf{Y_i}} (< \textbf{1000}), \textit{\textbf{M_i}} (≤ \textbf{10}), and \textit{\textbf{D_i}} (≤ \textbf{20}), that correspond to the year, month and day, respectively, of a person's birthdate in the king's calendar. These three numbers are separated by a space. \OutputFile For the birthdate specified in each dataset, print in a line the number of days from the birthdate, inclusive, to the millennium day, exclusive. Output lines should not contain any character other than this number.
Time limit 2 seconds
Memory limit 64 MiB
Input example #1
8
1 1 1
344 3 1
696 5 1
182 9 5
998 8 7
344 2 19
696 4 19
999 10 20
Output example #1
196470
128976
59710
160715
252
128977
59712
1
Source ACM ICPC Asia Regional Contest 2012 Tokyo