human
Can you solve the below in CPP?
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

Give me a the Python code you requested?
assistant
#Here is the Python code you requested.

#include <bits/stdc++.h>
using namespace std;
struct pt {
  int x, y;
  pt() {}
  pt(int xx, int yy) {
    x = xx;
    y = yy;
  }
  pt(string s) {
    x = s[0] - 'a';
    y = s[1] - '1';
    cerr << x << " " << y << "\n";
  }
  bool operator==(const pt &a) { return x == a.x && y == a.y; }
  int len(const pt &a) { return (x - a.x) * (x - a.x) + (y - a.y) * (y - a.y); }
  int ln(const pt &a) {
    return abs(x + y - a.x - a.y) + (a.x - x) * (a.y - y) * 100;
  }
};
pt rook1, rook2, wk, bk;
bool def = false;
bool check(pt k) {
  if (min(k.x, k.y) < 0) return true;
  if (max(k.x, k.y) >= 8) return true;
  if (k == rook1 && !def && wk.len(rook1) > 2) return false;
  if (k == rook2 && !def && wk.len(rook2) > 2) return false;
  if ((k.x == rook1.x || k.y == rook1.y) &&
      wk.ln(k) + wk.ln(rook1) != k.ln(rook1))
    return true;
  if ((k.x == rook2.x || k.y == rook2.y) &&
      wk.ln(k) + wk.ln(rook2) != k.ln(rook2))
    return true;
  if (wk.len(k) <= 2) return true;
  return false;
}
int main() {
  string r1, r2, k1, k2;
  cin >> r1 >> r2 >> k1 >> k2;
  rook1 = pt(r1);
  rook2 = pt(r2);
  wk = pt(k1);
  bk = pt(k2);
  if ((rook1.x == rook2.x || rook1.y == rook2.y) &&
      wk.ln(rook1) + wk.ln(rook2) != rook1.ln(rook2))
    def = true;
  if (!check(bk)) {
    cout << "OTHER\n";
    return 0;
  }
  if (!check(pt(bk.x, bk.y - 1))) {
    cout << "OTHER\n";
    return 0;
  }
  if (!check(pt(bk.x, bk.y + 1))) {
    cout << "OTHER\n";
    return 0;
  }
  if (!check(pt(bk.x - 1, bk.y - 1))) {
    cout << "OTHER\n";
    return 0;
  }
  if (!check(pt(bk.x - 1, bk.y))) {
    cout << "OTHER\n";
    return 0;
  }
  if (!check(pt(bk.x - 1, bk.y + 1))) {
    cout << "OTHER\n";
    return 0;
  }
  if (!check(pt(bk.x + 1, bk.y - 1))) {
    cout << "OTHER\n";
    return 0;
  }
  if (!check(pt(bk.x + 1, bk.y))) {
    cout << "OTHER\n";
    return 0;
  }
  if (!check(pt(bk.x + 1, bk.y + 1))) {
    cout << "OTHER\n";
    return 0;
  }
  cout << "CHECKMATE\n";
}