#arc107e. [arc107_e]Mex Mat

[arc107_e]Mex Mat

Problem Statement

Consider an NtimesNN \\times N matrix. Let us denote by ai,ja_{i, j} the entry in the ii-th row and jj-th column. For ai,ja_{i, j} where i=1i=1 or j=1j=1 holds, its value is one of 00, 11 and 22 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 mathrmmex(x,y)\\mathrm{mex}(x, y) is defined by the following table:

mathrmmex(x,y)\\mathrm{mex}(x, y)

y=0y=0

y=1y=1

y=2y=2

x=0x=0

11

22

11

x=1x=1

22

00

00

x=2x=2

11

00

00

How many entries of the matrix are 0,1,0, 1, and 22, respectively?

Constraints

  • 1leqNleq500,0001 \\leq N \\leq 500{,}000
  • ai,ja_{i,j}'s given in input are one of 00, 11 and 22.

Input

Input is given from Standard Input in the following format:

NN a1,1a_{1, 1} a1,1a_{1, 1} ...... a1,Na_{1, N} a2,1a_{2, 1} :: aN,1a_{N, 1}

Output

Print the number of 00's, 11's, and 22'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