A knight attacks the squares shown in the figure below (the knight on square S attacks the squares marked with a cross).

You are given a chessboard of size 3×n with 3 rows and n columns, where 1≤n≤100, together with a set Z of blocked squares. Rows are numbered from top to bottom as 1 through 3, and columns from left to right as 1 through n.
Knights may be placed only on squares that are not in Z, and no two placed knights may attack each other. At most one square in each column belongs to Z. The set Z is given by a sequence k1,k2,…,kn with each ki∈{0,1,2,3}: if ki=0 then no square in column i is blocked, otherwise ki is the row index of the single blocked square in column i.
Compute the maximum number of knights M that can be placed under these rules, and L, the number of distinct placements of exactly M knights.
The first line contains one integer n (1≤n≤100), the number of columns. Each of the next n lines contains one integer from {0,1,2,3}, giving the terms k1,k2,…,kn that describe Z.
Print two integers M and L separated by a single space: the maximum number of knights, and the number of placements that achieve this maximum.