PROGRAMMING:snooker
Zhenhai middle school has set up many school-based elective courses, such as sports, music, art, radio direction finding, aviation, navigation and aerospace model making, so as to enable each student to learn a good interest after graduating from high school, and lay a foundation for future lifelong development. Among the school-based elective courses of physical education, one is snooker billiards.
There are 21 balls in snooker billiards competition, including 15 red balls and 6 colored balls (yellow, green, brown, blue, pink and black). Party A and Party B play in turn. 1 point for a red ball and 1 point for a colored ball
Yellow ball: 2 points; Green ball: 3 points; Brown ball: 4 points;
Basketball: 5 points; Powder ball: 6 points; Black ball: 7 points;
The winner is the one with the highest score.
The simplified playing rules are as follows:
1. If there is a red ball, it must be played for the odd number of times, and the played red ball shall be taken away from the table;
2. After playing a red ball, you can choose a color ball at will. After playing a red ball, the color ball will not be taken away from the table;
3. If there is no red ball to play on the table, then play the colored ball in the order of score from small to large. At this time, each colored ball is taken away from the table.
The penalties for fouls are as follows:
1. If you don't hit the ball, add 4 points to the opponent;
2. Failing to play the ball according to the rules, that is, hitting the wrong ball:
(1) If the score of the wrong ball is greater than 4, then add the score of the ball to the opponent;
(2) If the score of the wrong ball is no more than 4, add 4 points to the opponent;
The wrong ball is not removed from the table.
Please count the score of a game so far.
###Input format:
The first line has two integers n and m, which means that a has played n balls and B has played m balls. N and m are separated by a space.
In the second line, there are n integers separated by spaces, representing the N times of continuous play of A.
In the third line, there are m integers separated by spaces, representing the m times of continuous playing of B.
In the second and third lines:
(1) The integers from 1 to 7 represent the balls with corresponding scores;
(2) The last number is 0, which means that no foul has been hit. 0 will only appear at the last number of the two lines;
(3) The foul of playing the wrong ball will only appear at the last number of the two lines;
Input data to ensure that it is correct, will not appear to hit the table does not exist on the ball, the data does not have to check.
###Output format:
There is only one line. There are two integers in this line (separated by a space), which indicates the score of a and B so far in the game (the first one is the first one).
###Input sample 1:
```in
4 3
1 7 1 6
1 7 1
```
###Output sample 1:
```out
15 9
```
[example 1]
A played red ball, black ball, red ball and pink ball in turn, and got 15 points (1 + 7 + 1 + 6);
B played red ball, black ball, red ball in turn, B got 9 points (1 + 7 + 1);
###Input sample 2:
```in
11 24
1 7 1 7 1 7 1 7 1 7 1
1 7 1 7 1 7 1 7 1 7 1 7 1 7 1 7 1 7 2 3 4 5 6 7
```
###Output sample 2:
```out
41 99
```
[example 2]
A plays a black ball after each red ball (5 times in total), and the last one is a red ball
5*(1+7)+1=41;;
B plays a black ball after each red ball. After playing all the red balls, he scores all the yellow, green, brown, blue, pink and black balls according to the rules, and gets 99 points: 9 * (1 + 7) + 2 + 3 + 4 + 5 + 6 + 7 = 99;
answer:If there is no answer, please comment
There are 21 balls in snooker billiards competition, including 15 red balls and 6 colored balls (yellow, green, brown, blue, pink and black). Party A and Party B play in turn. 1 point for a red ball and 1 point for a colored ball
Yellow ball: 2 points; Green ball: 3 points; Brown ball: 4 points;
Basketball: 5 points; Powder ball: 6 points; Black ball: 7 points;
The winner is the one with the highest score.
The simplified playing rules are as follows:
1. If there is a red ball, it must be played for the odd number of times, and the played red ball shall be taken away from the table;
2. After playing a red ball, you can choose a color ball at will. After playing a red ball, the color ball will not be taken away from the table;
3. If there is no red ball to play on the table, then play the colored ball in the order of score from small to large. At this time, each colored ball is taken away from the table.
The penalties for fouls are as follows:
1. If you don't hit the ball, add 4 points to the opponent;
2. Failing to play the ball according to the rules, that is, hitting the wrong ball:
(1) If the score of the wrong ball is greater than 4, then add the score of the ball to the opponent;
(2) If the score of the wrong ball is no more than 4, add 4 points to the opponent;
The wrong ball is not removed from the table.
Please count the score of a game so far.
###Input format:
The first line has two integers n and m, which means that a has played n balls and B has played m balls. N and m are separated by a space.
In the second line, there are n integers separated by spaces, representing the N times of continuous play of A.
In the third line, there are m integers separated by spaces, representing the m times of continuous playing of B.
In the second and third lines:
(1) The integers from 1 to 7 represent the balls with corresponding scores;
(2) The last number is 0, which means that no foul has been hit. 0 will only appear at the last number of the two lines;
(3) The foul of playing the wrong ball will only appear at the last number of the two lines;
Input data to ensure that it is correct, will not appear to hit the table does not exist on the ball, the data does not have to check.
###Output format:
There is only one line. There are two integers in this line (separated by a space), which indicates the score of a and B so far in the game (the first one is the first one).
###Input sample 1:
```in
4 3
1 7 1 6
1 7 1
```
###Output sample 1:
```out
15 9
```
[example 1]
A played red ball, black ball, red ball and pink ball in turn, and got 15 points (1 + 7 + 1 + 6);
B played red ball, black ball, red ball in turn, B got 9 points (1 + 7 + 1);
###Input sample 2:
```in
11 24
1 7 1 7 1 7 1 7 1 7 1
1 7 1 7 1 7 1 7 1 7 1 7 1 7 1 7 1 7 2 3 4 5 6 7
```
###Output sample 2:
```out
41 99
```
[example 2]
A plays a black ball after each red ball (5 times in total), and the last one is a red ball
5*(1+7)+1=41;;
B plays a black ball after each red ball. After playing all the red balls, he scores all the yellow, green, brown, blue, pink and black balls according to the rules, and gets 99 points: 9 * (1 + 7) + 2 + 3 + 4 + 5 + 6 + 7 = 99;
answer:If there is no answer, please comment