#arc107e. [arc107_e]Mex Mat
[arc107_e]Mex Mat
Problem Statement
Consider an matrix. Let us denote by the entry in the -th row and -th column. For where or holds, its value is one of , and and given in the input. The remaining entries are defined as follows:
- $a_{i,j} = \\mathrm{mex}(a_{i-1,j}, a_{i,j-1}) (2 \\leq i, j \\leq N)$ where is defined by the following table:
How many entries of the matrix are and , respectively?
Constraints
- 's given in input are one of , and .
Input
Input is given from Standard Input in the following format:
Output
Print the number of 's, 's, and 's separated by whitespaces.
Sample Input 1
4
1 2 0 2
0
0
0
Sample Output 1
7 4 5
The matrix is as follows:
1 2 0 2
0 1 2 0
0 2 0 1
0 1 2 0