시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
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

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