This page is still under construction.

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

JOI Sort

Interview

Time limit2sMemory limit1024 MB

Summary
Given a string of J, O, and I characters, rearrange it so every J precedes every O, and every O precedes every I.
Level

Easy2 of 10

Topics
Sorting, Implementation, String
Solved
No attempts yet

Problem

You are given a string S of length N. Each character of S is one of 'J', 'O', or 'I'.

You want to rearrange the characters of S so that the following conditions hold.

  • For every pair of a character 'J' and a character 'O', the 'J' comes before the 'O'.
  • For every pair of a character 'O' and a character 'I', the 'O' comes before the 'I'.
  • For every pair of a character 'J' and a character 'I', the 'J' comes before the 'I'.

Given a string S, write a program that prints a string obtained by rearranging the characters of S so that the conditions above hold.

Input

The input is given from standard input in the following format.

N
S

Output

Print a string obtained by rearranging the characters of S so that the conditions hold.

Constraints

  • 1 ≦ N ≦ 100.
  • S is a string of length N.
  • Each character of S is one of 'J', 'O', or 'I'.

Examples3

  1. Example 1

    Input
    6
    JIOIJO
    
    Expected output
    JJOOII
    
  2. Example 2

    Input
    4
    OOOI
    
    Expected output
    OOOI
    
  3. Example 3

    Input
    10
    OIJJJIOIOI
    
    Expected output
    JJJOOOIIII