Under construction

Still being built. Things may change

Hockey Match

Interview

Time limit1sMemory limit1024 MB

Summary
Given partial hockey statistics for two teams, fill in every value that is uniquely determined by the constraints and leave the rest as -1.
Level

Medium4 of 10

Topics
Math, Implementation, Brute force
Solved
No attempts yet

Problem

Malin loves watching ice hockey. Unfortunately, she had far too much homework last night and could not watch the live broadcast of her favorite team's latest match, so now she is curious about what happened during the match.

Usually she goes to Kvällspappret's sports pages to find out, but unfortunately a large part of their website is broken (they need better programmers, as good as PO participants) and only a certain part of the statistics can be read. Malin is mainly interested in three things for each team: the number of goals they scored, the number of shots their goalkeeper saved, and the total number of shots they took at the opponent's goal. Given part of this statistics for each team, reconstruct as much of the statistics as possible.

Input

The first line contains three integers: the number of saves the first team's goalkeeper made, the number of goals scored by the first team, and the number of shots the first team took at the opponent's goal. The second line contains the corresponding information for the second team.

All numbers in the statistics that are known are between 00 and 10910^9. If a number in the statistics is missing, it is replaced by −1-1.

It is guaranteed that there is at least one way to replace all −1-1 with numbers so that the resulting statistics are correct.

Output

Print the statistics for the two teams in the same format as the input. All missing statistics that can be uniquely determined from the other numbers must be printed instead of −1-1. If a certain number cannot be uniquely determined, print −1-1.

Examples3

  1. Example 1

    Input
    1 -1 3
    2 4 -1
    
    Expected output
    1 1 3
    2 4 5
    
  2. Example 2

    Input
    -1 -1 1
    1 -1 0
    
    Expected output
    0 0 1
    1 0 0
    
  3. Example 3

    Input
    -1 -1 -1
    -1 -1 -1
    
    Expected output
    -1 -1 -1
    -1 -1 -1