Under construction

Still being built. Things may change

Window Blinds

Time limit1sMemory limit128 MB

Summary
Parse a grid of ASCII-drawn window blinds and count how many of the M×N windows show each of five possible blind heights.
Level

Easy3 of 10

Topics
Simulation, Implementation, String
Solved
No attempts yet

Problem

Given the window states of the apartment across the street, count how many windows have each possible blind height.

Each window is represented as a 4×4 grid. * is a lowered part of the blind, and . is a visible part of the window. Only the following five states can appear; they have 0, 1, 2, 3, or 4 rows of * from the top.

0 rows:

....
....
....
....

1 row:

****
....
....
....

2 rows:

****
****
....
....

3 rows:

****
****
****
....

4 rows:

****
****
****
****

The apartment has M floors, and each floor has N windows. Given the current state of the whole apartment, determine how many windows are in each of the five states.

Input

The first line contains two space-separated integers M and N. (1 ≤ M, N ≤ 100)

The next 5M+1 lines describe the apartment. Each line contains 5N+1 characters. Each window is a 4×4 grid, and # characters separate windows and form the borders.

Output

Output five integers separated by spaces: the number of windows in each of the five states, in the order shown above. The sum of the five numbers must be M×N.

Examples2

  1. Example 1

    Input
    1 2
    ###########
    #....#****#
    #....#****#
    #....#....#
    #....#....#
    ###########
    
    Expected output
    1 0 1 0 0
    
  2. Example 2

    Input
    2 3
    ################
    #****#****#****#
    #****#****#****#
    #****#....#****#
    #....#....#****#
    ################
    #....#****#****#
    #....#****#....#
    #....#....#....#
    #....#....#....#
    ################
    
    Expected output
    1 1 2 1 1