This page is still under construction.

Parts of this page are still being built. What you see may change.

Hidden Roman Numerals

Time limit1sMemory limit1024 MB

Summary
Find which of the twelve Roman numerals from 1 to 12 appear as substrings of a given string over {I,V,X}.
Level

Easy2 of 10

Topics
String, Implementation, Brute force
Solved
No attempts yet

Problem

Bronius is learning the Roman numerals from 1 to 12. These numbers can be written using only three symbols — I, V, and X — as follows:

123456789101112
IIIIIIIVVVIVIIVIIIIXXXIXII

For practice, Bronius wrote on the board a random string s1s2…sNs_1 s_2 \dots s_N of length NN made up of the symbols I, V, and X. He then looks for the Roman numerals from 1 to 12 that are hidden in the string. A number is hidden in the string if its Roman representation appears as a contiguous substring. For example, the string XIIIX hides the numbers 1, 2, 3, 9, 10, 11, 12.

Find all numbers from 1 to 12 that are hidden in the string Bronius wrote.

Input

The first line contains a positive integer NN, the length of the string.

The second line contains the NN symbols sis_i with no spaces. Each symbol is one of I, V, or X.

Output

Print, on a single line, all numbers hidden in the string in increasing order, separated by spaces.

Constraints

  • 1≤N≤1001 \le N \le 100
  • si∈{I,V,X}s_i \in \{\text{I}, \text{V}, \text{X}\}

Examples5

  1. Example 1

    Input
    5
    XIIIX
    
    Expected output
    1 2 3 9 10 11 12
    
  2. Example 2

    Input
    1
    I
    
    Expected output
    1
    
  3. Example 3

    Input
    1
    V
    
    Expected output
    5
    
  4. Example 4

    Input
    1
    X
    
    Expected output
    10
    
  5. Example 5

    Input
    4
    VIII
    
    Expected output
    1 2 3 5 6 7 8