Signal

Interview

Time limit1sMemory limit512 MB

Summary
Decode a 5-row pixel strip into digits: 3-column glyphs except 1, separated by blank columns.
Level

Medium5 of 10

Topics
Implementation, Array, String
Solved
No attempts yet

Problem

zxcvber is a scientist who studies aliens. He has spent the last 10 years studying signals coming from space, but without any results. Then one day, strange signals suddenly began arriving from space. Overjoyed, zxcvber received the signals and analyzed them. A signal consists of 0s and 1s, and here, for convenience, 0 is written as "." and 1 is written as "#". The signal was as follows.

###.....###.#..####.#.......#.#....####.....###.#....##.#.......#.#....####.....###.#....#

After analyzing several other signals, zxcvber found that the length of a signal is always a multiple of 5. Thinking that splitting a signal into five parts might reveal some pattern, zxcvber split the signal into five signals of equal length. Then something surprising happened. The picture below shows the split signal with "#" as black and "." as white.

The signal was representing digital digits! Column 1-3 showed 8, columns 9-11 showed 3, column 13 showed 1, and columns 16-18 showed 7. Believing these digits had a special meaning, zxcvber began decoding other signals as well. However, the signals were too long to check by hand one by one. Still, while analyzing short signals, zxcvber was able to figure out the rules of signals.

1. A signal consists of "." and "#".
2. The decoded result of a signal always contains at least one digit.
3. Every "#" appearing in a signal is part of a valid digit pattern.
4. There is at least one blank column between digits. Here, a blank column means a column in which all components are ".".
5. The digits 0 to 9 are shown below. Again, "#" is shown as black and "." as white.

Note that 1, unlike the other digits, occupies 1 column. Help zxcvber decode the signal!

Input

The first line of input gives the length of the signal N (5 ≤ N ≤ 100,000, N is a multiple of 5).

The next line gives the signal. Only signals that follow the rules zxcvber found are given as input.

Output

On the first line, print the digits obtained by decoding the signal, in order.

Hint

Reading the sample signal in blocks of 8 gives the following.

Examples1

  1. Example 1

    Input
    40
    ###..#..#.#..#..###..#..#.#..#..###..#..
    
    Expected output
    81