题目描述
Problem Description
Naota-kun and Naoko-san are twins. Sometimes, they play games together on holidays.
The game is based on Tic-Tac-Toe and is played as follows:
- The game uses a board with 3 squares vertically and 3 squares horizontally. At the start of the game, no squares are filled with any characters.
- After greeting each other, they start writing characters alternately, starting with Naota-kun. Characters can only be written on squares that are not already filled. If there are multiple such squares, they can choose any one. Naota-kun writes circles (○), and Naoko-san writes crosses (×).
- After a total of 9 characters are written, all squares are filled. Then, the score is calculated, and the one with the higher score wins.
The score is calculated as follows. Here, the top-left square is called square (1, 1), and the square that is i-1 (1 ≦ i ≦ 3) squares down and j-1 (1 ≦ j ≦ 3) squares to the right from the top-left is called square (i, j).
- For all integer pairs (i, j) satisfying 1 ≦ i ≦ 2 and 1 ≦ j ≦ 3, if the squares (i, j) and (i+1, j) have the same character, Naota-kun gets b_{i,j} points; if they have different characters, Naoko-san gets b_{i,j} points.
- For all integer pairs (i, j) satisfying 1 ≦ i ≦ 3 and 1 ≦ j ≦ 2, if the squares (i, j) and (i, j+1) have the same character, Naota-kun gets c_{i,j} points; if they have different characters, Naoko-san gets c_{i,j} points.
Both Naota-kun and Naoko-san play the game to maximize their final scores. Calculate their scores when both play optimally.
Input Format
The input is given from the standard input in the following format:
b_{1,1} b_{1,2} b_{1,3} b_{2,1} b_{2,2} b_{2,3} c_{1,1} c_{1,2} c_{2,1} c_{2,2} c_{3,1} c_{3,2}
- The first line contains three integers b_{1,1} (0 ≦ b_{1,1} ≦ 100), b_{1,2} (0 ≦ b_{1,2} ≦ 100), and b_{1,3} (0 ≦ b_{1,3} ≦ 100) separated by spaces.
- The second line contains three integers b_{2,1} (0 ≦ b_{2,1} ≦ 100), b_{2,2} (0 ≦ b_{2,2} ≦ 100), and b_{2,3} (0 ≦ b_{2,3} ≦ 100) separated by spaces.
- The third line contains two integers c_{1,1} (0 ≦ c_{1,1} ≦ 100) and c_{1,2} (0 ≦ c_{1,2} ≦ 100) separated by spaces.
- The fourth line contains two integers c_{2,1} (0 ≦ c_{2,1} ≦ 100) and c_{2,2} (0 ≦ c_{2,2} ≦ 100) separated by spaces.
- The fifth line contains two integers c_{3,1} (0 ≦ c_{3,1} ≦ 100) and c_{3,2} (0 ≦ c_{3,2} ≦ 100) separated by spaces.
Output Format
The output consists of two lines. The first line should contain Naota-kun's score, and the second line should contain Naoko-san's score. Ensure to add a newline at the end of the output.
Sample Input and Output
Sample Input #1
0 15 0
0 0 25
20 10
0 0
25 0
Sample Output #1
15
80
Sample Input #2
18 22 15
11 16 17
4 25
22 15
10 4
Sample Output #2
72
107
Notes/Hints
Sample Explanation 1
- For example, consider the case where characters are written in the order of squares (2,1) → (1,1) → (2,2) → (1,3) → (1,2) → (2,3) → (3,1) → (3,2) → (3,3). In this case, the board will look like this: ×○×○○×○×○
- In this case, Naota-kun's score is (b_{1,2} + b_{1,3} + b_{2,1} + c_{1,2} = ) 15 + 0 + 0 + 0 = 15 points.
- On the other hand, Naoko-san's score is (b_{1,1} + b_{2,2} + b_{2,3} + c_{1,1} + c_{1,2} + c_{2,2} + c_{3,1} + c_{3,2} = ) 0 + 0 + 25 + 20 + 10 + 0 + 25 + 0 = 80 points.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分