Baseball is a bat-and-ball game played between two teams of nine players. The sport is very popular in North America and parts of Central and South America, the Caribbean and East Asia, but less popular in Europe. The teams switch between batting and fielding whenever the fielding team records three outs. One turn batting for both teams, beginning with the visiting team, constitutes an inning. A game comprises nine innings, and the team with the greater number of runs at the end of the game wins. Baseball is the only major team sport in America with no game clock, although almost all games end in the ninth inning.

baseball field
In a baseball game, the batting team attempts to score runs by hitting a ball that is thrown by the pitcher with a bat swung by the batter, then running counter-clockwise around a series of four bases (indicated by the white squares): first, second, third and home plate (bottom white square in the figure). A run is scored when a player advances around the bases and returns to home plate. Players on the batting team take turns hitting against the pitcher of the fielding team, which tries to prevent runs by getting hitters out in any of several ways. A player of the batting team who reaches a base safely can later attempt to advance to subsequent bases during teammates' turns batting, such as on a hit or by other means. A home run is scored when the ball is hit in such a way that the batter is able to circle the bases and reach home safely in one play without any errors being committed by the defensive team in the process.

The batting team attempts to score runs by hitting a ball that is thrown by the pitcher with a bat swung by the batter, then running counter-clockwise around a series of four bases (indicated by the white squares in the figure above): first, second, third and home plate (bottom white square in the figure). A run is scored when a player advances around the bases and returns to home plate. Players on the batting team take turns hitting against the pitcher of the fielding team, which tries to prevent runs by getting hitters out in any of several ways. A player of the batting team who reaches a base safely can later attempt to advance to subsequent bases during teammates' turns batting, such as on a hit or by other means. A home run is scored when the ball is hit in such a way that the batter is able to circle the bases and reach home safely in one play without any errors being committed by the defensive team in the process.

Assignment

During a baseball game, only the first, second and third base may be occupied. We will therefore represent the occupied bases during game play by a sequence (list or tuple) that may only contain the integers (int) 1 (first base), 2 (second base) and 3 (third base). The integers are always arranged in increasing order.

We only consider $$\mathbf{n}$$-base hits, where $$n \in \mathbb{N}$$ and $$0 \leq n \leq 4$$. With a $$0$$-base hit the batter could not hit the ball correctly, and is not allowed to enter the field (so that he can not score a point). With an $$n$$-base hit ($$0 < n \leq 4$$) all players of the batting team on the field (the batter and the players occupying bases) advance $$n$$ bases counter-clockwise around the field. All players that return to home plate upon this hit score a point and leave the field. A home run is therefore equal to a 4-base hit.

honkbal
There are no occupied bases at the start of a batting turn, which is represented by an empty sequence (situation on the left). In case the first batter strikes a 2-base hit, he runs over first base to second base. If the second batter then strikes a 1-base hit, he runs to first base and the first batter advances to third base. If the third batter then strikes a 3-base hit, he runs to third base and the first two batters that occupied first and third base each score one point because they reach the home plate.

There are no occupied bases at the start of a batting turn, which is represented by an empty sequence (situation on the left in the above figure). In case the first batter strikes a 2-base hit, he runs over first base to second base. If the second batter then strikes a 1-base hit, he runs to first base and the first batter advances to third base. If the third batter then strikes a 3-base hit, he runs to third base and the first two batters that occupied first and third base each score one point because they reach the home plate.

Your task:

Example

>>> hit(2)
(0, [2])
>>> hit(0, [1, 3])
(0, [1, 3])
>>> hit(1, (1, 3))
(1, [1, 2])
>>> hit(2, occupied=[1, 3])
(1, [2, 3])
>>> hit(3, occupied=(1, 3))
(2, [3])
>>> hit(4, occupied=[1, 3])
(3, [])

>>> inning([0, 1, 2, 3, 4])
(4, [])
>>> inning((4, 3, 2, 1, 0))
(2, [1, 3])
>>> inning([1, 1, 2, 1, 0, 0, 1, 3, 0])
(5, [3])