#P7742. Channel Menu Adjustment

    ID: 20929 Type: Default 1000ms 256MiB

Channel Menu Adjustment

Channel Menu Adjustment

Mirko's grandparents used to watch only two channels, BLJTV1 and BLJTV2, on their old analog TV. After switching to a digital receiver they gained access to many channels but still only want to see the two old channels. In the channel menu, an arrow indicates the currently selected channel. When the menu is opened, the arrow starts at index 0 (the first channel). You are given a list of unique channel names which always includes BLJTV1 and BLJTV2. There are four available operations, each represented by a number:

  1. Move the arrow down one position (from channel \(i\) to channel \(i+1\)).
  2. Move the arrow up one position (from channel \(i\) to channel \(i-1\)).
  3. Swap the channel at the arrow with the channel below it (swap channels at positions \(i\) and \(i+1\); the arrow moves to position \(i+1\)).
  4. Swap the channel at the arrow with the channel above it (swap channels at positions \(i\) and \(i-1\); the arrow moves to position \(i-1\)).

Your task is to output any sequence of operations (each indicated by its corresponding number) such that after performing them, BLJTV1 is at the first position (index 0) and BLJTV2 is at the second position (index 1). The overall length of the operation sequence must be less than \(500\). The order of the remaining channels is arbitrary.

inputFormat

The input begins with an integer \(n\) (\(2 \le n \le 100\)), representing the number of channels. Following that are \(n\) lines, each containing a distinct channel name. Note that the list always includes BLJTV1 and BLJTV2.

outputFormat

Output a single line containing a sequence of operation numbers (from the set {1,2,3,4}) separated by spaces. When these operations are applied in order, they rearrange the channel list so that BLJTV1 is at index 0 and BLJTV2 is at index 1.

sample

3
BLJTV1
BLJTV2
ABC