跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2035. Game of chess unfinished

    ID: 2041 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>模拟编程与模拟进阶难度共享题库Codeforces英文题面题目来源题面语言

Game of chess unfinished

题目描述

B. Game of chess unfinished
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", − Volodya said and was right for sure. And your task is to say whether whites had won or not.

Pieces on the chessboard are guaranteed to represent a correct position (every piece occupies one cell, no two pieces occupy the same cell and kings cannot take each other). Thus, your task is only to decide whether whites mate blacks. We would remind you that it means that the black king can be taken by one of the opponent's pieces at the moment and also it cannot move to an unbeaten position. A rook moves vertically or horizontally by any number of free cells (assuming there are no other pieces on its path), a king − to the adjacent cells (either by corner or by side). Certainly, pieces cannot leave the board. The black king might be able to take opponent's rooks at his turn (see sample 3).

Input

The input contains 4 space-separated piece positions: positions of the two rooks, the white king and the black king. Each position on 8×8 chessboard is denoted by two symbols − ('a' - 'h') and ('1' - '8') − which stand for horizontal and vertical coordinates of the cell occupied by the piece. It is guaranteed, that no two pieces occupy the same cell, and kings cannot take each other.

Output

Output should contain one word: "CHECKMATE" if whites mate blacks, and "OTHER" otherwise.

Examples
Input
a6 b4 c8 a8
Output
CHECKMATE
Input
a6 c4 b6 b8
Output
OTHER
Input
a2 b1 a3 a1
Output
OTHER

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1626 题。保留原作者与原赛事署名。