QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100 Difficulty: [show] Hackable ✓

#24556. Travel

Statistics

Little R and Little X are going on a trip by high-speed train. They bought two second-class tickets, each showing a carriage number and a seat number. They hope their seats are adjacent so that they can sit together during the journey.

The train they are taking consists of $17$ carriages, numbered from 01 to 17. Among them, carriages 01 and 16 are first-class carriages, and the remaining carriages are second-class carriages. Both of them bought second-class tickets, so their seats are both in second-class carriages. Each second-class carriage has $18$ rows, with $5$ seats in each row. A seat number consists of a two-digit row number and an uppercase letter; for example, 03C represents seat C in row $3$. The seats in each row are arranged from left to right with seat letters A, B, C, D, F in order, where the aisle is between seat C and seat D; that is, the sequence of seats to the left of the aisle in each row is A, B, C, and to the right is D, F. Below is a schematic diagram of the seats in a second-class carriage:

problem_24556_244e5912ed2448b3cd8b5b9146867833.png

Two seats are adjacent if and only if they are in the same row of the same carriage, on the same side of the aisle, and adjacent in the seat sequence on that side.

You need to help Little R determine, in order:

  • Whether the seats corresponding to the two tickets are in the same carriage;
  • Whether the seats corresponding to the two tickets are in the same row of the same carriage;
  • Whether the seats corresponding to the two tickets are in the same row of the same carriage and on the same side of the aisle;
  • Whether the seats corresponding to the two tickets are adjacent.

Input

The first line of input contains four strings $c_1, s_1, c_2, s_2$, representing the carriage number and seat number on Little R's ticket, and the carriage number and seat number on Little X's ticket, respectively.

Output

Output a single line containing a 01 string of length $4$, representing the answers to the four questions in order, where 1 means yes and 0 means no.

Examples

Input 1

02 01A 02 01B

Output 1

1111

Note

Carriage 02 is a second-class carriage. 01A and 01B are in the same carriage, the same row, on the same side of the aisle, and are adjacent, so output 1111.

Input 2

02 01C 02 01A

Output 2

1110

Note

The two seats are in the same carriage, the same row, and on the same side of the aisle, but 01B is between 01C and 01A, so they are not adjacent; therefore, output 1110.

Input 3

02 01C 02 01D

Output 3

1100

Input 4

02 02B 02 01A

Output 4

1000

Input 5

02 01A 03 01A

Output 5

0000

Constraints

For all test data:

  • $c_1, c_2$ are two-digit carriage numbers between 01 and 17, excluding 01 and 16;
  • $s_1, s_2$ are valid seat numbers in the corresponding carriages, meaning the first two characters form a row number between 01 and 18, and the last character is one of the letters A, B, C, D, F;
  • The two tickets do not correspond to the same seat, i.e., $c_1 \ne c_2$ or $s_1 \ne s_2$.
Test Case No. Special Properties
$1 \sim 4$ A, B, C
$5 \sim 10$ A, B
$11 \sim 14$ A
$15 \sim 17$ D
$18 \sim 20$ None

Special Property A: The two seats are in the same carriage, i.e., $c_1 = c_2$.

Special Property B: The two seats are in the same row, i.e., the first two characters of $s_1$ are the same as the first two characters of $s_2$.

Special Property C: The two seats are on the same side of the aisle.

Special Property D: Little R's seat is seat D and Little X's seat is seat F, i.e., the last character of $s_1$ is D and the last character of $s_2$ is F.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.