Problem list
Log in
#r03555 · CCC 2019 Senior

Flipper

Bronze II 2.0 s 256 MB

You are trying to pass the time while at the optometrist. You notice there is a grid of four numbers:

1 2
3 4

You see lots of mirrors and lenses at the optometrist, and wonder how flipping the grid horizontally or vertically would change the grid.

Specifically, a “horizontal” flip (across the horizontal centre line) would take the original grid of four numbers and result in:

3 4
1 2

A “vertical” flip (across the vertical centre line) would take the original grid of four numbers and result in:

2 1
4 3

Your task is to determine the final orientation of the numbers in the grid after a sequence of horizontal and vertical flips.

Input

The input consists of one line, composed of a sequence of at least one and at most 1 000 000 characters. Each character is either H, representing a horizontal flip, or V, representing a vertical flip.

For 8 of the 15 available marks, there will be at most 1 000 characters in the input.

Output

Output the final orientation of the four numbers. Specifically, each of the two lines of output will contain two integers, separated by one space.

Example 1

Input
HV
Output
4 3
2 1

Example 2

Input
VVHH
Output
1 2
3 4
Source
CCC 2019 Senior
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code