Under construction

Still being built. Things may change

Hawk Eyes

Interview

Time limit1sMemory limit512 MB

Summary
Given a sequence of cup swaps among four positions, track where the small ball (initially at position 1) and big ball (initially at position 4) end up.
Level

Easy3 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

Jaeyeol is good at the shell game, and he plans to earn some money by running a booth in front of Hongmungwan during the festival.

Jaeyeol places four cups in a row on a table. He puts a small ball in the leftmost cup and a big ball in the rightmost cup. He will then mix the cups many times, each time swapping the positions of two cups. When he is done, he will ask his opponent which cups hold the balls. With 4 cups there are 6 ways to swap two positions, shown in the figures below.

Number the positions 1, 2, 3, 4 from the left. Each way swaps these two positions:

WayPositions swapped
A1 and 2
B1 and 3
C1 and 4
D2 and 3
E2 and 4
F3 and 4

Jaeyeol practiced for 3 months to make a fortune, and almost nobody can beat him. By chance, Yeongbeom, who has extraordinary dynamic visual acuity, is walking past Hongmungwan. Yeongbeom proposes a bet, and Jaeyeol, unaware of anything, silently starts mixing the cups. However fast Jaeyeol's hands are, they cannot fool Yeongbeom's eyes. Yeongbeom also has an excellent memory and remembers the entire order in which Jaeyeol mixed the cups. Jaeyeol does not know this, and his fate depends on the program you write.

Given the ways Jaeyeol mixed the cups in order, write a program that prints the position of the cup holding the small ball and then the position of the cup holding the big ball.

Input

The first line contains the order in which Jaeyeol mixes the cups, as a string without spaces. Each character is one of A, B, C, D, E, F from the figures above. Jaeyeol mixes the cups at most 200 times.

Output

Print the position of the small ball on the first line and the position of the big ball on the second line. Positions are numbered 1, 2, 3, 4 from the left.

Examples1

  1. Example 1

    Input
    AB
    
    Expected output
    2
    4