Hide

Problem G
Cafeteria (Easy)

Theta likes to play Lure of the Labyrinth, which is an online game that uses a compelling graphic novel storyline to engage middle grades students in mathematical thinking and problem-solving. To find lost pets, students have to infiltrate a world of monsters and solve puzzles! Implemented by a professional game studio, these puzzles are quite engaging and challenging.

In the manager’s cafeteria, students are asked to practice proportions by serving $5$ monsters sitting at the table: Salamander, Yeti, Golem, Imp, and Kraken. Each monster wants some amount of burger, slop, sushi, and drumstick.

The amount of each item each monster wants on their plate is proportional to the amount of each of the other items that monster wants, and the proportionality ratio is the same for all monsters.

For instance, as shown in sample input $1$ and in the accompanying figure, if Golem (center) wants $6$ units of burger on his plate and $12$ units of drumstick, and Salamander (left) wants $40$ units of drumstick, then Salamander will want $20$ units of burger. Students practicing proportions will program the dispenser machine to release $20$ units of burger. Similarly, Kraken (right) wants $36$ units of drumstick because it has $81$ units of slop on its plate and Salamander has $40$ units of drumstick and $90$ units of slop. If the students compute all proportions in time, the monsters eat and a pet can be saved!

As students progress in the game and reach more difficult levels, fewer and fewer amounts are given, requiring more intuition and thinking to solve the puzzle.

Give a set of partially filled plates, write a program that computes the amount of food for the remaining slots!

Input

The input consists of $2$ lines of $10$ entries each describing the partially filled plates. The first line describes the top row (burgers and slop), the second line describes the bottom row (sushi and drumstick). On each line, the first $2$ entries describe Salamander’s plate, the next $2$ Yeti’s, then Golem’s, Imp’s, and finally Kraken’s. Each entry is either the underscore character _ describing an empty slot or a positive integer number $a$ ($0 < a \le 200$) if it is already known. Entries are separated by single spaces. There are at least $8$ slots given. You may assume that all plates have at least one non-empty slot, and that for each kind of food there exists one plate where its amount is known.

Output

Output two lines showing how many units of food should be on each plate in the same format as given in the input: the top line lists the amounts of burgers and slop for each plate, the bottom line lists the amounts of sushi and drumstick. Separate each amount with a space.

Sample Input 1 Sample Output 1
_ 90 22 _ 6 _ _ _ _ 81
_ 40 _ _ _ 12 60 _ 90 _
20 90 22 99 6 27 12 54 18 81 
100 40 110 44 30 12 60 24 90 36 

Please log in to submit a solution to this problem

Log in