CCC '08 S5 - Nukit


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem types
Allowed languages
C++, Python
Canadian Computing Competition: 2016 Stage 1, Junior #4

Fiona commutes to work each day. If there is no rush-hour traffic, her commute time is 2 hours. However, there is often rush-hour traffic. Specifically, rush-hour traffic occurs from 07:00 (7am) until 10:00 (10am) in the morning and 15:00 (3pm) until 19:00 (7pm) in the afternoon. During rush-hour traffic, her speed is reduced by half.

She leaves either on the hour (at XX:00 ), 20 minutes past the hour (at XX:20 ), or 40 minutes past the hour (at XX:40 ).

Given Fiona's departure time, at what time does she arrive at work?

Input Specification

The input will be one line, which contains an expression of the form HH:MM , in which HH is one of the 24 starting hours ( 00 , 01 , ..., 23 ) and MM is one of the three possible departure minute times ( 00 , 20 , 40 ).

Output Specification

Output the time of Fiona's arrival, in the form , one B , and two D particles all at the same time on a turn.

It turns out that, no matter how many particles start off in the reactor, exactly one of Patrick or Roland has a perfect winning strategy . By player X has a perfect winning strategy , we mean that no matter what the other player does, player X can always win by carefully choosing reactions. For example, if the reactor starts off with one A , five B , and three D particles then Roland has the following perfect winning strategy: "if Patrick forms reaction BBB initially, then form reaction AD afterward; if Patrick forms reaction AD initially, then form reaction BBB afterward." (The strategy works because either way, on Patrick's second turn, there are not enough particles left to form any reactions.)

Given the number of each type of particle initially in the reactor, can you figure out who has a perfect winning strategy?

Input Specification

The first line of input contains \(n\) , the number of test cases \((1 < n < 100)\) . Each test case consists of 4 integers separated by spaces on a single line; they represent the initial number of A , B , C and D particles. You can assume that there are initially between \(0\) and \(30\) (inclusive) of each type of particle.

For test cases worth 75% of points there will initially be between \(0\) and \(8\) (inclusive) of each type of particle. This subtask is equivalent to the constraints that were used in the version of this problem on the Junior competition.

Output Specification

For each test case, output the player who has a perfect winning strategy, either Roland or Patrick .

Sample Input

6
0 2 0 2
1 3 1 3
1 5 0 3
3 3 3 3
8 8 6 7
8 8 8 8

Output for Sample Input

Roland
Patrick
Roland
Roland
Roland
Patrick

Partial Explanation for Sample Output

The first output occurs since Patrick loses immediately, since he cannot form any reaction. (Roland's perfect winning strategy is "do nothing.")

The second output occurs since Patrick has the perfect winning strategy "form reaction ABCD ," which makes Roland lose on his first turn.

The third output is explained in the problem statement.


Comments

There are no comments at the moment.