Increment the count of first element of the row
if ( cnt . has ( mat [ i ] [ 0 ] ) ) { cnt . set ( mat [ i ] [ 0 ] , cnt . get ( mat [ i ] [ 0 ] ) + 1 ) ; } else { cnt . set ( mat [ i ] [ 0 ] , 1 ) ; }