시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 7 2 2 33.333%

문제

왼쪽에서 오른쪽으로 늘어선 N개의 열린 박스들이 있다. 각각의 박스에는 정확하게 두개의 공이 있다. 그리고 각각의 공은 흰색 또는 검은색이다.

첫번째(가장 왼쪽) 박스 위에 크레인이 있다. 그리고 우리는 다음 커맨드를 통해 크레인을 조작할 수 있다.

  • LIJEVO 크레인을 왼쪽 박스로 옮긴다
  • DESNO 크레인을 오른쪽 박스로 옮긴다
  • UZMI BIJELU 아래의 박스로부터 흰색 공을 꺼낸다
  • UZMI CRNU 아래의 박스로부터 검은색 공을 꺼낸다
  • SPUSTI BIJELU 아래의 박스에 흰색 공을 떨어뜨린다
  • SPUSTI CRNU 아래의 박스에 검은색 공을 떨어뜨린다

크레인은 공 두개 까지만 들 수 있다. 반면 각각의 박스에 넣을 수 있는 공의 수에는 제한이 없다.

우리는 다음 조건들이 만족되었을때 공이 "정렬되었다"라고 말한다.

  • 각각의 박스에는 같은색의 공이 정확히 두개씩 있다
  • 흰색 공으로 채워진 어떤 두 박스 사이에 검은색 공으로 채워진 박스는 존재하지 않는다
  • 검은색 공으로 채워진 어떤 두 박스 사이에 흰색 공으로 채워진 박스는 존재하지 않는다

위의 조건을 만족시키도록하는 커맨드의 최소 절차를 찾는 프로그램을 작성하라.

당신의 답에 있는 각각의 커맨드는 유효해야한다(크레인은 가장 왼쪽 박스로부터 왼쪽으로 갈 수없다, 크레인은 2개를 넘는 공을 들어서는 안된다, 등등...).

입력

입력의 첫번째 줄에는 정수 N이 주어진다, 2 ≤ N ≤ 500.

두번째 줄에는 N개의 각 박스에 포함된 내용물을 나타내는 이니셜이 차례대로 주어진다.

각 박스에는 'B' 또는 'C'인 두개의 문자가 있다. 문자 'B'는 흰색 공을 나타내고 문자 'C'는 검은색 공을 나타낸다.

출력

각 줄에 하나씩, 모든 커맨드를 출력하라.

테스트 데이터는 유일하진 않더라도, 항상 해법이 존재한다.

예제 입력 1

3
C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