#P9791. [NERC 2018] Alice the Fan

[NERC 2018] Alice the Fan

Background

Translated from Problem A of NERC 2018.

Problem Description

Alice likes watching volleyball matches, and she especially likes watching Team A. The rules of a volleyball match are as follows:

  • A match has at most 55 sets.

  • In the first 44 sets, a team must score at least 2525 points to win the set. In the 55th set, only 1515 points are required.

  • If, within a set, one side meets the winning condition but the score difference between the two sides is less than 22, it is not considered a win.

  • A team that wins 33 sets wins the match, and the match ends immediately at that moment.

Now you are given the numbers of sets won by Team A and Team B, and you need to determine the best possible match score for Team A, or determine that the match has not ended yet.

(Note: In this problem, the “best” match score is defined as follows: if Team A can win, make the difference in the number of sets between the two teams as large as possible; otherwise, make it as small as possible.)

Input Format

The first line contains an integer m(1m50000)m(1 \leq m \leq 50000), indicating that Team A has played mm different matches.

The next mm lines each contain two integers a(1a200)a(1 \leq a \leq 200) and b(1b200)b(1 \leq b \leq 200), representing the points scored by Team A and Team B in that match.

Output Format

For each match, output Team A’s best match score situation and one set-by-set score sequence that satisfies the conditions, or determine that it is impossible and output Impossible.

6
75 0
90 90
20 0
0 75
78 50
80 100
3:0
25:0 25:0 25:0
3:1
25:22 25:22 15:25 25:21
Impossible
0:3
0:25 0:25 0:25
3:0
25:11 28:26 25:13
3:2
25:17 0:25 25:22 15:25 15:11

Hint

The testdata guarantees that 1m500001 \leq m \leq 50000 and 1a,b2001 \leq a,b \leq 200.

Note: Due to technical reasons, if the SPJ shows UKE during judging, it is because there is an error in your code, causing the SPJ to read one more or one fewer character, and then it cannot judge normally.

Translated by ChatGPT 5