#C1414. Run-Length Encoding

    ID: 43756 Type: Default 1000ms 256MiB

Run-Length Encoding

Run-Length Encoding

You are given a sequence of characters. Your task is to compute its run-length encoding. In run-length encoding, consecutive sequences of the same character are replaced by a pair consisting of the character and the number of occurrences. For example, if the input sequence is a a b b b c c a a a a, then the output should be:

a 2
b 3
c 2
a 4

If the input list is empty, no output should be produced.

inputFormat

The first line of the input contains an integer n which represents the number of characters. The second line contains n space-separated characters.

outputFormat

For each contiguous group of the same character in the sequence, output a line containing the character followed by its count. If the sequence is empty, output nothing.

## sample
11
a a b b b c c a a a a
a 2

b 3 c 2 a 4

</p>