## WC '02 P1 - A Planning Session

View as PDF

Points: 5
Time limit: 1.0s
Memory limit: 16M

Problem type
##### Woburn Challenge 2002

The cows have been advancing steadily against a weak monkeys' front. The Head-Monkey, employing logic not used since the debacle of the Polish Un-Truth Table, decides to expose the monkeys' backs, hoping for better luck. Unfortunately, this tactic is not successful, and the monkeys are forced to retreat further into the deep recesses of Scarberia, with sore bottoms, no less.

The Head-Monkey decides it's time for action. But before anything can be done, a meeting must be called to decide what must be done. And in this meeting, several debates must be fought, each lasting several hours, and each leading to the inevitable conclusion, "Just leave it as it was last year!" The Head-Monkey sends forth word to her disciples to meet at the top of the Enchanted Tree at the next time when the digits of the time sum to a certain number, . Several of the younger monkeys want to continue playing their games for as long as possible, and consequently, want to know how many minutes are left before the meeting is to begin.

#### Input Specification

The first line of input contains a single integer , indicating the number of test cases. Each test case consists of two lines; the first line contains a string in the form :, where and , indicating the current time in Scarberia.
The second line contains a single integer, .

#### Output Specification

A single integer that is the number of minutes left before a meeting occurs or Infinite if a meeting never occurs. Note that the output will never be since we are asking for THE NEXT TIME when a meeting is possible.

#### Sample Input

3
11:59
3
01:00
15
12:11
33

#### Sample Output

1
59
Infinite