409863: GYM103811 G Gold Medal Bout

Memory Limit:256 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Gold Medal Bouttime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Today is the last day of the Tokyo 2020 Summer Olympic Games, with the closing ceremony going to take place tonight at 7PM HKT. In the last 16 days, Hong Kong Team has been continuously making history with by-far the best result of 1 Gold, 2 Silver and 3 Bronze Medals, bringing pride to all Hong Kong citizens. Such credit also belongs to all other Hong Kong athletes, even without medals, since they too have paid numerous effort and fought to their best.

Steve is particularly into this year's Olympics, especially when he saw two LSC Alumni participating in the Games: Choi Chun Yin Ryan (2015) in Fencing and Lam Siu-hang (2015) playing Table Tennis. The three matches played by Lam were tough, yet Lam was able to withstand the pressure and managed to make a comeback in both Round 1 and Round 2, before losing to Japan's world No. 4 Harimoto Tomokazu, still forcing the opponent into ties at 10-10 for three times.

Steve decides to learn more about table tennis rules. The scoring system is as follows:

  1. A player can win a game of table tennis by scoring 11 points. The first to 11 points is declared the winner of the game.
  2. If the points are tied at 10-10, a player then has to strive for a two-point lead to win the game.
  3. A table tennis match consists of multiple games. Singles matches are played best-of-seven, i.e. the first player to win 4 games wins the match.

To mark the end of the Tokyo 2020 Olympics, Steve challenges you with a little twist. Steve will pick any arbitrary match, sums up the points of all games, and tell you how much points each player scores, as well as the winner of the match. You then have to try to construct a possible set of game scores to satisfy all the conditions, or determine if such match result is impossible.

Input

A single line containing three integers $$$P_1, P_2, W$$$ – Player 1's total points, Player 2's total points, and which player wins the match. ($$$0 \le P_1, P_2 \le 1000, 1 \le W \le 2$$$)

Output

Output the match scores in the first line, followed by individual game points in each line.

If there are multiple set of solutions, output any of them. If there are no possible solutions, output -1.

ExamplesInput
69 63 1
Output
4 3
7 11
11 9
6 11
11 6
11 4
12 14
11 8
Input
61 65 1
Output
4 3
11 7
7 11
4 11
5 11
11 9
12 10
11 6
Input
51 56 2
Output
1 4
9 11
11 13
11 8
10 12
10 12
Input
45 0 1
Output
-1
Note

Samples 1-3 are the actual match results between Lam Siu-hang and (1) Brian Afanador from Puerto Rico, (2) Sathiyan Gnanasekaran from India, and (3) Harimoto Tomokazu from Japan.

加入题单

算法标签: