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).

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 should contain one word: "CHECKMATE" if whites mate blacks, and "OTHER" otherwise.

const dx:array[1..8] of longint=(-1,-1,0,1,1,1,0,-1);
      dy:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);
var a,b,aa,bb,c,cc,d,dd,i,j:longint;
    ch:char;
    e:array[0..9,0..9] of longint;

function check:boolean;
var i,x,y:longint;
begin
     check:=false;
     if e[d,dd]=0 then exit;
     for i:=1 to 8 do
     begin
          x:=d+dx[i]; y:=dd+dy[i];
          if (x>0) and (y>0) and (x<9) and (y<9) and (e[x,y]<=0) then exit;
     end;
     check:=true;
end;

begin
     read(ch); a:=ord(ch)-96; read(aa);
     read(ch,ch); b:=ord(ch)-96; read(bb);
     read(ch,ch); c:=ord(ch)-96; read(cc);
     read(ch,ch); d:=ord(ch)-96; read(dd);
     e[a,aa]:=-1; e[b,bb]:=-1; e[c,cc]:=-1;
     for i:=a-1 downto 1 do
         if e[i,aa]<0 then break else e[i,aa]:=1;
     for i:=a+1 to 8 do
         if e[i,aa]<0 then break else e[i,aa]:=1;
     for i:=b-1 downto 1 do
         if e[i,bb]<0 then break else e[i,bb]:=1;
     for i:=b+1 to 8 do
         if e[i,bb]<0 then break else e[i,bb]:=1;
     for i:=aa-1 downto 1 do
         if e[a,i]<0 then break else e[a,i]:=1;
     for i:=aa+1 to 8 do
         if e[a,i]<0 then break else e[a,i]:=1;
     for i:=bb-1 downto 1 do
         if e[b,i]<0 then break else e[b,i]:=1;
     for i:=bb+1 to 8 do
         if e[b,i]<0 then break else e[b,i]:=1;
     if (a=b) or (aa=bb) then
     begin
          e[a,aa]:=1; e[b,bb]:=1;
     end;
     for i:=1 to 8 do e[c+dx[i],cc+dy[i]]:=1;
     if check then writeln('CHECKMATE')
     else writeln('OTHER');
end.

var
   m : array [1..8,1..8] of boolean;
   a,b,c,d : array [1..2] of longint;
   flag : boolean;
   i,j : longint;
   s : string;
procedure put(x,y : longint);
begin
     if (x<1) then exit;
     if (x>8) then exit;
     if (y<1) then exit;
     if (y>8) then exit;
     m[x,y]:=true;
end;

function est(x,y : longint) : boolean;
var
    b : boolean;
begin
     b:=false;
     if (x<1) then b:=true;
     if (x>8) then b:=true;
     if (y<1) then b:=true;
     if (y>8) then b:=true;
     if b = false then est:=m[x,y] else est:=b;
end;

begin
     fillchar(m,sizeof(m),false);
     readln(s);
     a[1]:=ord(s[1])-ord('a')+1;
     b[1]:=ord(s[4])-ord('a')+1;
     c[1]:=ord(s[7])-ord('a')+1;
     d[1]:=ord(s[10])-ord('a')+1;
     a[2]:=ord(s[2])-ord('0');
     b[2]:=ord(s[5])-ord('0');
     c[2]:=ord(s[8])-ord('0');
     d[2]:=ord(s[11])-ord('0');
     for i:=1 to 8 do
         begin
              put(a[1]+i,a[2]);
              if (a[1]+i=c[1]) and (a[2]=c[2]) then break;
         end;
     for i:=1 to 8 do
         begin
              put(a[1]-i,a[2]);
              if (a[1]-i=c[1]) and (a[2]=c[2]) then break;
         end;
     for i:=1 to 8 do
         begin
              put(b[1]+i,b[2]);
              if (b[1]+i=c[1]) and (b[2]=c[2]) then break;
         end;
     for i:=1 to 8 do
         begin
              put(b[1]-i,b[2]);
              if (b[1]-i=c[1]) and (b[2]=c[2]) then break;
         end;

     for i:=1 to 8 do
         begin
              put(a[1],a[2]+i);
              if (a[1]=c[1]) and (a[2]+i=c[2]) then break;
         end;
     for i:=1 to 8 do
         begin
              put(a[1],a[2]-i);
              if (a[1]=c[1]) and (a[2]-i=c[2]) then break;
         end;
     for i:=1 to 8 do
         begin
              put(b[1],b[2]+i);
              if (b[1]=c[1]) and (b[2]+i=c[2]) then break;
         end;
     for i:=1 to 8 do
         begin
              put(b[1],b[2]-i);
              if (b[1]=c[1]) and (b[2]-i=c[2]) then break;
         end;
     put(c[1],c[2]);
     put(c[1]+1,c[2]);
     put(c[1]-1,c[2]);
     put(c[1],c[2]-1);
     put(c[1]+1,c[2]-1);
     put(c[1]-1,c[2]-1);
     put(c[1],c[2]+1);
     put(c[1]+1,c[2]+1);
     put(c[1]-1,c[2]+1);
{     if (a[1]=b[1]) or (a[2]=b[2]) then
        begin
             put(a[1],b[1]);
             put(a[2],b[2]);
        end;
}     flag:=true;
     if (not est(d[1]+1,d[2]+1)) then flag:=false;
     if (not est(d[1]+1,d[2]-1)) then flag:=false;
     if (not est(d[1]+1,d[2])) then flag:=false;
     if (not est(d[1]-1,d[2]+1)) then flag:=false;
     if (not est(d[1]-1,d[2]-1)) then flag:=false;
     if (not est(d[1]-1,d[2])) then flag:=false;
     if (not est(d[1],d[2]+1)) then flag:=false;
     if (not est(d[1],d[2]-1)) then flag:=false;
     if (not est(d[1],d[2])) then flag:=false;
     if flag = false then writeln('OTHER') else writeln('CHECKMATE');
end.

uses math;
var flag:boolean;
    a:array[-10..100,-10..100]of longint;
    x1,x2,x3,x4,y1,y2,y3,y4,i,j:longint;
    ch:char;
    procedure rec(x,y,xx,yy:longint);
     var w:longint;
     begin
       while (x+xx>0)and(x+xx<9) and (y+yy>0)and(y+yy<9) do
        begin
          x:=x+xx;
          y:=y+yy;
          w:=a[x,y];
          a[x,y]:=0;
          if w=2 then break;
        end;
     end;
  begin
    read(ch,y1);
    x1:=ord(ch)-96;
    read(ch,ch,y2);
    x2:=ord(ch)-96;
    read(ch,ch,y3);
    x3:=ord(ch)-96;
    read(ch,ch,y4);
    x4:=ord(ch)-96;

    for i:=0 to 9 do
     for j:=0 to 9 do
      a[i,j]:=0;
     for i:=1 to 8 do
     for j:=1 to 8 do
      a[i,j]:=1;
    a[x1,y1]:=2;
    a[x2,y2]:=2;
    a[x3,y3]:=2;
    a[x4,y4]:=3;

    rec(x1,y1,1,0);
    rec(x1,y1,-1,0);
    rec(x1,y1,0,1);
    rec(x1,y1,0,-1);

    rec(x2,y2,1,0);
    rec(x2,y2,-1,0);
    rec(x2,y2,0,1);
    rec(x2,y2,0,-1);

    for i:=1 to 8 do
     for j:=1 to 8 do
      if ( max(abs(x3-i),abs(y3-j))=1 ) then a[i,j]:=0;

    flag:=true;
    for i:=1 to 8 do
     for j:=1 to 8 do
      if ( max(abs(x4-i),abs(y4-j))<=1 ) and (a[i,j]>0) then flag:=false;
    if flag then writeln('CHECKMATE')
            else writeln('OTHER');
  End.

var board:array[1..8,1..8]of boolean;
    a:string[11];
    r,l,i,j,kr,kl:byte;
    ischeckmate:boolean;
begin
    for i:=1 to 8 do for j:=1 to 8 do board[i,j]:=false;
    readln(a);
    {white king}
    r:=ord(a[8])-48;
    kr:=r;
    l:=ord(a[7])-96;
    kl:=l;
    for i:=r-1 to r+1 do
        for j:=l-1 to l+1 do
            if (i<9)and(i>0)and(j<9)and(j>0) then
                board[i,j]:=true;
    {1st rook}
    r:=ord(a[2])-48;
    l:=ord(a[1])-96;
    for i:=1 to 8 do begin
        if i<>l then
            if (kr=r) then begin
                if ((kl<l)and(kl<i))or((kl>l)and(kl>i)) then
                    board[r,i]:=true
            end
            else
                board[r,i]:=true;
        if i<>r then
            if (kl=l) then begin
                if ((kr<r)and(kr<i))or((kr>r)and(kr>i)) then
                    board[i,l]:=true
            end
            else
                board[i,l]:=true;
    end;
    {2nd rook}
    r:=ord(a[5])-48;
    l:=ord(a[4])-96;
    for i:=1 to 8 do begin
        if i<>l then
            if (kr=r) then begin
                if ((kl<l)and(kl<i))or((kl>l)and(kl>i)) then
                    board[r,i]:=true
            end
            else
                board[r,i]:=true;
        if i<>r then
            if (kl=l) then begin
                if ((kr<r)and(kr<i))or((kr>r)and(kr>i)) then
                    board[i,l]:=true
            end
            else
                board[i,l]:=true;
    end;
    ischeckmate:=true;
    {black king}
    r:=ord(a[11])-48;
    l:=ord(a[10])-96;
    for i:=r-1 to r+1 do begin
        for j:=l-1 to l+1 do
            if (i<9)and(i>0)and(j<9)and(j>0)and(board[i,j]=false) then begin
                ischeckmate:=false;
                break;
            end;
        if ischeckmate=false then break;
    end;
    if ischeckmate then
        writeln('CHECKMATE')
    else
        writeln('OTHER');
readln;
end.

const x:array[1..9] of longint=(0,1,1,1,0,-1,-1,-1,0);
      y:array[1..9] of longint=(0,1,0,-1,-1,-1,0,1,1);
var x1,y1,x2,y2,x3,y3,x4,y4,i,j,k:longint;
    s:string;
    s1,s2,s3,s4:string;
    sim1,sim2:char;
    a,b:array[0..9,0..9] of longint;

procedure Print(s:string);
begin
writeln(s);
halt;
end;

function BOY:boolean;
var i1,i2,j1,j2,i,j,l:longint;
    t:extended;
    pp:boolean;
begin
 for i1:= 1 to 8 do
 for j1:= 1 to 8 do
   if a[i1,j1]=4 then begin
                       for i2:= 1 to 8 do
                       for j2:= 1 to 8 do
                        begin
                         if (a[i2,j2]=1) or (a[i2,j2]=2) then begin
                                                               if i1=i2 then begin
                                                                              if j1<J2 then begin
                                                                                pp:=true;
                                                                                for l:= j1+1 to j2-1 do
                                                                                if a[i1,l]<>0 then pp:=false;
                                                                                if pp then begin BOY:=true; exit; end;
                                                                                end else
                                                                                begin
                                                                                pp:=true;
                                                                                for l:= j2+1 to j1-1 do
                                                                                if a[i1,l]<>0 then pp:=false;
                                                                                if pp then begin BOY:=true; exit; end;
                                                                                end;
                                                                             end else
                                                               if j1=j2 then begin
                                                                              if i1<I2 then begin
                                                                                pp:=true;
                                                                                for l:= i1+1 to i2-1 do
                                                                                if a[l,j1]<>0 then pp:=false;
                                                                                if pp then begin BOY:=true; exit; end;
                                                                                end else
                                                                                begin
                                                                                pp:=true;
                                                                                for l:= i2+1 to i1-1 do
                                                                                if a[l,j1]<>0 then pp:=false;
                                                                                if pp then begin BOY:=true; exit; end;
                                                                                end;
                                                                             end;
                                                              end else
                         if (a[i2,j2]=3) then begin
                                               t:=sqrt(Sqr(i1-i2)+sqr(j1-j2));
                                               if t<1.9 then begin BOY:=true; exit; end;

                                              end;
                        end;
                       end;
BOY:=false;
end;

begin
readln(s);
x1:=ord(s[1])-ord('a')+1;
y1:=ord(s[2])-ord('1')+1;
x2:=ord(s[4])-ord('a')+1;
y2:=ord(s[5])-ord('1')+1;
x3:=ord(s[7])-ord('a')+1;
y3:=ord(s[8])-ord('1')+1;
x4:=ord(s[10])-ord('a')+1;
y4:=ord(s[11])-ord('1')+1;
s1:='OTHER';
s2:='CHECKMATE';
for i:= 1 to 8 do
for j:= 1 to 8 do
a[i,j]:=0;
a[x1,y1]:=1;
a[x2,y2]:=2;
a[x3,y3]:=3;
a[x4,y4]:=9;
b:=a;
 for k:= 1 to 9 do
   begin
    if (x4+x[k]<1) or (y4+y[k]<1) or (x4+x[k]>8) or (y4+y[k]>8) then continue;
    a:=b;
    a[x4,y4]:=0;
    a[x4+x[k],y4+y[k]]:=4;
    if not BOY then begin Print(s1); end;
   end;
  Print(s2);
end.

var
ff,n,m,i,j,x1,y1,x2,y2,x3,y3,x4,y4:longint;
xx,yy,nn:char;
a:array[0..10,0..10]of longint;

procedure ha;
    begin
     writeln('OTHER');
     halt(0);
    end;

function f(q,w:longint):boolean;
var i,j:longint;
 begin
  if (q<1)or(q>8)or(w<1)or(w>8) then
    begin
     f:=false;
     exit;
    end;

  ff:=a[q,w];
  a[q,w]:=0;

  if ((abs(q-x3)=1)or(abs(w-y3)=1))and((abs(q-x3))+(abs(w-y3))<=2) then
    begin
     f:=false;
  a[q,w]:=ff;
     exit;
    end;

  if y1=w then
  for i:=x1+1 to n do
    begin
     if a[i,y1]<>0 then break;

     if (i=q) then
       begin
        f:=false;
  a[q,w]:=ff;
        exit;
       end;
    end;

  if y1=w then
  for i:=x1-1 downto 1 do
    begin
     if a[i,y1]<>0 then break;

     if (i=q) then
       begin
        f:=false;
  a[q,w]:=ff;
        exit;
       end;
    end;

  if x1=q then
  for j:=y1+1 to m do
    begin
     if a[x1,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
  a[q,w]:=ff;
        exit;
       end;
    end;

  if x1=q then
  for j:=y1-1 downto 1 do
    begin
     if a[x1,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
  a[q,w]:=ff;
        exit;
       end;
    end;

  if y2=w then
  for i:=x2+1 to n do
    begin
     if a[i,y2]<>0 then break;

     if (i=q) then
       begin
        f:=false;
  a[q,w]:=ff;
        exit;
       end;
    end;

  if y2=w then
  for i:=x2-1 downto 1 do
    begin
     if a[i,y2]<>0 then break;

     if (i=q) then
       begin
        f:=false;
  a[q,w]:=ff;
        exit;
       end;
    end;

  if x2=q then
  for j:=y2+1 to m do
    begin
     if a[x2,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
  a[q,w]:=ff;
        exit;
       end;
    end;

  if x2=q then
  for j:=y2-1 downto 1 do
    begin
     if a[x2,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
  a[q,w]:=ff;
        exit;
       end;
    end;

  a[q,w]:=ff;
  f:=true;
 end;

 begin
  n:=8;
  m:=8;
  fillchar(a,sizeof(a),0);
  read(xx,yy);
  x1:=ord(xx)-96;
  y1:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x2:=ord(xx)-96;
  y2:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x3:=ord(xx)-96;
  y3:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x4:=ord(xx)-96;
  y4:=ord(yy)-48;

  a[x1,y1]:=1;

  a[x2,y2]:=2;

  a[x3,y3]:=3;

  if f(x4,y4) then ha;

  for i:=-1 to 1 do
    for j:=-1 to 1 do
      if (i<>0)or(j<>0) then if f(x4+i,y4+j) then ha;

  writeln('CHECKMATE');
 end.

uses math;
var flag:boolean;
    a:array[-10..100,-10..100]of longint;
    x1,x2,x3,x4,y1,y2,y3,y4,i,j:longint;
    ch:char;
    procedure rec(x,y,xx,yy:longint);
     var w:longint;
     begin
       while (x+xx>0)and(x+xx<9) and (y+yy>0)and(y+yy<9) do
        begin
          x:=x+xx;
          y:=y+yy;
          w:=a[x,y];
          a[x,y]:=0;
          if w=2 then break;
        end;
     end;
  begin
    read(ch,y1);
    x1:=ord(ch)-96;
    read(ch,ch,y2);
    x2:=ord(ch)-96;
    read(ch,ch,y3);
    x3:=ord(ch)-96;
    read(ch,ch,y4);
    x4:=ord(ch)-96;

    for i:=0 to 9 do
     for j:=0 to 9 do
      a[i,j]:=0;
     for i:=1 to 8 do
     for j:=1 to 8 do
      a[i,j]:=1;
    a[x1,y1]:=2;
    a[x2,y2]:=2;
    a[x3,y3]:=2;
    a[x4,y4]:=3;

    rec(x1,y1,1,0);
    rec(x1,y1,-1,0);
    rec(x1,y1,0,1);
    rec(x1,y1,0,-1);

    rec(x2,y2,1,0);
    rec(x2,y2,-1,0);
    rec(x2,y2,0,1);
    rec(x2,y2,0,-1);

    for i:=1 to 8 do
      for j:=1 to 8 do
        if (max(abs(x3-i),abs(y3-j))=1) then a[i,j]:=0;

    flag:=true;
    for i:=1 to 8 do
     for j:=1 to 8 do
      if ( max(abs(x4-i),abs(y4-j))<=1 ) and (a[i,j]>0) then flag:=false;
    if flag then writeln('CHECKMATE')
            else writeln('OTHER');
  End.

program sdfdsv;

var i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;
	ch:char;
	f,g,h:array[0..9,0..9] of byte;
	r:integer;

BEGIN

read(ch);
if ch='a' then i1:=1;
if ch='b' then i1:=2;
if ch='c' then i1:=3;
if ch='d' then i1:=4;
if ch='e' then i1:=5;
if ch='f' then i1:=6;
if ch='g' then i1:=7;
if ch='h' then i1:=8;
read(ch);
Val(ch,j1,r);
read(ch);
read(ch);
if ch='a' then i2:=1;
if ch='b' then i2:=2;
if ch='c' then i2:=3;
if ch='d' then i2:=4;
if ch='e' then i2:=5;
if ch='f' then i2:=6;
if ch='g' then i2:=7;
if ch='h' then i2:=8;
read(ch);
Val(ch,j2,r);
read(ch);
read(ch);
if ch='a' then i3:=1;
if ch='b' then i3:=2;
if ch='c' then i3:=3;
if ch='d' then i3:=4;
if ch='e' then i3:=5;
if ch='f' then i3:=6;
if ch='g' then i3:=7;
if ch='h' then i3:=8;
read(ch);
Val(ch,j3,r);
read(ch);
read(ch);
if ch='a' then i4:=1;
if ch='b' then i4:=2;
if ch='c' then i4:=3;
if ch='d' then i4:=4;
if ch='e' then i4:=5;
if ch='f' then i4:=6;
if ch='g' then i4:=7;
if ch='h' then i4:=8;
read(ch);
Val(ch,j4,r);
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(i=i2)or(j=j1)or(j=j2) then begin
if ((i1=i3)and(i1=i)and((j1-j3)*(j-j3)<0))or((j1=j3)and(j1=j)and((i1-i3)*(i-i3)<0))or((i2=i3)and(i2=i)and((j2-j3)*(j-j3)<0))or((j2=j3)and(j1=j)and((i2-i3)*(i-i3)<0)) then begin
if ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1
end
else f[i,j]:=1;
end;
if ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;
end;
end;
for i:=0 to 9 do f[i,0]:=1;
for i:=0 to 9 do f[i,9]:=1;
for j:=1 to 8 do f[0,j]:=1;
for j:=1 to 8 do f[9,j]:=1;

for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i2)or(j=j2) then begin
if ((i2=i3)and(i2=i)and((j2-j3)*(j-j3)<0))or((j2=j3)and(j1=j)and((i2-i3)*(i-i3)<0)) then begin
if ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;
end
else g[i,j]:=1;
end;
if ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;
end;
end;
for i:=0 to 9 do g[i,0]:=1;
for i:=0 to 9 do g[i,9]:=1;
for j:=1 to 8 do g[0,j]:=1;
for j:=1 to 8 do g[9,j]:=1;

for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(j=j1) then begin
if ((i1=i3)and(i1=i)and((j1-j3)*(j-j3)<0))or((j1=j3)and(j1=j)and((i1-i3)*(i-i3)<0)) then begin
if ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;
end
else h[i,j]:=1;
end;
if ((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;
end;
end;
for i:=0 to 9 do h[i,0]:=1;
for i:=0 to 9 do h[i,9]:=1;
for j:=1 to 8 do h[0,j]:=1;
for j:=1 to 8 do h[9,j]:=1;
if (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4-1,j4+1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4+1,j4]=1)and(f[i4+1,j4+1]=1) then
begin
if ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')
else writeln('CHECKMATE');
end
else writeln('OTHER');
END.

const
  hx:array[1..9] of longint=(1,1,1,0,0,-1,-1,-1,0);
  hy:array[1..9] of longint=(0,1,-1,1,-1,0,-1,1,0);

var
  s:string;
  x1,y1,x2,y2,bx,by,wx,wy,i,cx,cy,res:longint;
  w1,was:array[1..8,1..8] of boolean;

begin
  readln(s);
  x1:=ord(s[1])-96;
  y1:=ord(s[2])-48;
  x2:=ord(s[4])-96;
  y2:=ord(s[5])-48;
  wx:=ord(s[7])-96;
  wy:=ord(s[8])-48;
  bx:=ord(s[10])-96;
  by:=ord(s[11])-48;
  for i:=1 to 8 do begin
    cx:=wx+hx[i];
    cy:=wy+hy[i];
    if (cx<1)or (cy<1) or (cx>8) or (cy>8) then continue;
    was[cx][cy]:=true;
  end;

  for i:=x1+1 to 8 do begin
    if (i=wx) and (y1=wy)then break;
    w1[i][y1]:=true;
  end;
  for i:=y1-1 downto 1 do begin
    if (i=wy) and (x1=wx)then break;
    w1[x1][i]:=true;
  end;
  for i:=y1+1 to 8 do begin
    if (i=wy) and (x1=wx)then break;
    w1[x1][i]:=true;
  end;
  for i:=x1-1 downto 1 do begin
    if (i=wx) and (y1=wy)then break;
    w1[i][y1]:=true;
  end;

  for i:=x2+1 to 8 do begin
    if (i=wx) and (y2=wy)then break;
    w1[i][y2]:=true;
  end;
  for i:=y2-1 downto 1 do begin
    if (i=wy) and (x2=wx)then break;
    w1[x2][i]:=true;
  end;
  for i:=y2+1 to 8 do begin
    if (i=wy) and (x2=wx)then break;
    w1[x2][i]:=true;
  end;
  for i:=x2-1 downto 1 do begin
    if (i=wx) and (y2=wy)then break;
    w1[i][y2]:=true;
  end;

  res:=0;
  for i:=1 to 9 do begin
    cx:=bx+hx[i];
    cy:=by+hy[i];
    if (cx<1)or (cy<1) or (cx>8) or (cy>8)then inc(res) else
    if (was[cx][cy])then inc(res) else
    if (w1[cx][cy]) then inc(res) else
    if (w1[cx][cy]) then inc(res);
  end;
  if (res=9)
    then writeln('CHECKMATE')
    else writeln('OTHER');
end.

type Tpos=record x,y:byte; end;
var p:array[1..4]of Tpos;
    ax:array[1..4]of string[3];
    board:array[0..9,0..9]of shortint;
    mat:boolean;
    i,x,y,j:shortint;
begin
 for y:=0 to 9 do
  for x:=0 to 9 do
   if ((x=0)or(x=9)or(y=0)or(y=9)) then
    board[x,y]:=5 else board[x,y]:=0;

 for i:=1 to 4 do begin
  read(ax[i]);
  p[i].x:=1 + (ord(ax[i,1])-ord('a'));
  p[i].y:=1 + (ord(ax[i,2])-ord('1'));
  if (i<4) then board[p[i].x,p[i].y]:=-1;
 end;

 for i:=1 to 2 do begin
  y:=p[i].y;
  for x:=p[i].x downto 1 do
   if (x<>p[i].x) then
    if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);
  for x:=p[i].x to 8 do
   if (x<>p[i].x) then
    if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);
  x:=p[i].x;
  for y:=p[i].y downto 1 do
   if (y<>p[i].y) then
    if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);
  for y:=p[i].y to 8 do
   if (y<>p[i].y) then
    if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);
 end;

 for i:=1 to 3 do board[p[i].x,p[i].y]:=-board[p[i].x,p[i].y]-1;

 for y:=-1 to 1 do
  for x:=-1 to 1 do
   if ((x<>0)or(y<>0))then inc(board[p[3].x+x,p[3].y+y]);

 if (board[p[4].x,p[4].y]<>0) then mat:=true else mat:=false;

 for y:=-1 to 1 do
  if mat then
   for x:=-1 to 1 do
    if ((y<>0)or(x<>0))then
     if (board[p[4].x+x,p[4].y+y]=0) then begin mat:=false; break; end;

 if mat then write('CHECKMATE') else write('OTHER');
end.

var
    d:array [1..8,1..8] of byte;
    i,j,n,k,x,y,xx,yy,x1,x2,y1,y2:longint;
    s:string;
BEGIN
fillchar(d,sizeof(d),0);
readln(s);
n:=1;
while n<=10 do
    begin
    j:=ord(s[n])-96;
    val(s[n+1],i);
    if n=1 then
        begin
        x1:=i;
        y1:=j;
        end
        else if n=4 then
            begin
            x2:=i;
            y2:=j;
            end
            else if n=7 then
                begin
                xx:=i;
                yy:=j;
                d[xx,yy]:=2;
                end
                else
                    begin
                    x:=i;
                    y:=j;
                    end;
    inc(n,3);
    end;

if x1<>xx then for k:=1 to 8 do d[x1,k]:=4
    else if y1<yy then for k:=1 to yy-1 do d[x1,k]:=4
        else for k:=yy+1 to 8 do d[x1,k]:=4;
if y1<>yy then for k:=1 to 8 do d[k,y1]:=4
    else if x1<xx then for k:=1 to xx-1 do d[k,y1]:=4
        else for k:=xx+1 to 8 do d[k,y1]:=4;
if x2<>xx then for k:=1 to 8 do d[x2,k]:=4
    else if y2<yy then for k:=1 to yy-1 do d[x2,k]:=4
        else for k:=yy+1 to 8 do d[x2,k]:=4;
if y2<>yy then for k:=1 to 8 do d[k,y2]:=4
    else if x2<xx then for k:=1 to xx-1 do d[k,y2]:=4
        else for k:=xx+1 to 8 do d[k,y2]:=4;

if (x1<>x2)and(y1<>y2) then
    begin
    d[x1,y1]:=1;
    d[x2,y2]:=1;
    end;

if xx>1 then d[xx-1,yy]:=4;
if xx<8 then d[xx+1,yy]:=4;
if yy>1 then d[xx,yy-1]:=4;
if yy<8 then d[xx,yy+1]:=4;
if (xx>1)and(yy>1) then d[xx-1,yy-1]:=4;
if (xx<8)and(yy<8) then d[xx+1,yy+1]:=4;
if (yy>1)and(xx<8) then d[xx+1,yy-1]:=4;
if (yy<8)and(xx>1) then d[xx-1,yy+1]:=4;

n:=0;k:=0;
if d[x,y]=4 then
    begin
    if x>1 then
        begin
        if d[x-1,y]=4 then inc(n);
        inc(k);
        end;
    if x<8 then
        begin
        if d[x+1,y]=4 then inc(n);
        inc(k);
        end;
    if y>1 then
        begin
        if d[x,y-1]=4 then inc(n);
        inc(k);
        end;
    if y<8 then
        begin
        if d[x,y+1]=4 then inc(n);
        inc(k);
        end;
    if (x>1)and(y>1) then
        begin
        if d[x-1,y-1]=4 then inc(n);
        inc(k);
        end;
    if (x<8)and(y<8) then
        begin
        if d[x+1,y+1]=4 then inc(n);
        inc(k);
        end;
    if (y>1)and(x<8) then
        begin
        if d[x+1,y-1]=4 then inc(n);
        inc(k);
        end;
    if (y<8)and(x>1) then
        begin
        if d[x-1,y+1]=4 then inc(n);
        inc(k);
        end;
    if n=k then writeln('CHECKMATE') else writeln('OTHER');
    end
else writeln('OTHER');

{for i:=1 to 8 do
    begin
    for j:=1 to 8 do
        if d[i,j]=0 then write('- ') else write(d[i,j],' ');
    writeln;
    end;}
END.

uses math;
Var ok:boolean;
  b:array[0..10,0..10]of longint;
  x1,x2,x3,x4,x,vx,y1,y2,y3,y4,y,vy,i,j,p,q:integer;
  s:string;
  Begin
    Readln(s);
    x1:=ord(s[1])-96;
    val(s[2],y1,p);
    x2:=ord(s[4])-96;
    val(s[5],y2,p);
    x3:=ord(s[7])-96;
    val(s[8],y3,p);
    x4:=ord(s[10])-96;
    val(s[11],y4,p);
    fillchar(b,sizeof(b),0);
    for i:=1 to 8 do
      for j:=1 to 8 do
        b[i,j]:=1;
    b[x1,y1]:=2;
    b[x2,y2]:=2;
    b[x3,y3]:=2;
    b[x4,y4]:=3;
    x:=x1;
    y:=y1;
    vx:=1;
    vy:=0;
    While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do
      begin
        x:=x+vx;
        y:=y+vy;
        q:=b[x,y];
        b[x,y]:=0;
        if q=2 then break;
      end;
    x:=x1;
    y:=y1;
    vx:=-1;
    vy:=0;
    While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do
      begin
        x:=x+vx;
        y:=y+vy;
        q:=b[x,y];
        b[x,y]:=0;
        if q=2 then break;
      end;
    x:=x1;
    y:=y1;
    vx:=0;
    vy:=1;
    While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do
      begin
        x:=x+vx;
        y:=y+vy;
        q:=b[x,y];
        b[x,y]:=0;
        if q=2 then break;
      end;
    x:=x1;
    y:=y1;
    vx:=0;
    vy:=-1;
    While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do
      begin
        x:=x+vx;
        y:=y+vy;
        q:=b[x,y];
        b[x,y]:=0;
        if q=2 then break;
      end;
    x:=x2;
    y:=y2;
    vx:=1;
    vy:=0;
    While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do
      begin
        x:=x+vx;
        y:=y+vy;
        q:=b[x,y];
        b[x,y]:=0;
        if q=2 then break;
      end;
    x:=x2;
    y:=y2;
    vx:=-1;
    vy:=0;
    While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do
      begin
        x:=x+vx;
        y:=y+vy;
        q:=b[x,y];
        b[x,y]:=0;
        if q=2 then break;
      end;
    x:=x2;
    y:=y2;
    vx:=0;
    vy:=1;
    While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do
      begin
        x:=x+vx;
        y:=y+vy;
        q:=b[x,y];
        b[x,y]:=0;
        if q=2 then break;
      end;
    x:=x2;
    y:=y2;
    vx:=0;
    vy:=-1;
    While (x+vx<=8)and(y+vy<=8)and(y+vy>=1)and(x+vx>=1) do
      begin
        x:=x+vx;
        y:=y+vy;
        q:=b[x,y];
        b[x,y]:=0;
        if q=2 then break;
      end;
    for i:=1 to 8 do
      for j:=1 to 8 do
        if (max(abs(x3-i),abs(y3-j))=1) then b[i,j]:=0;
    ok:=false;
    for i:=1 to 8 do
      for j:=1 to 8 do
        if (max(abs(x4-i),abs(y4-j))<=1)and(b[i,j]<>0) then ok:=true;
    if ok then Writeln('OTHER')
    else Writeln('CHECKMATE');
  End.

program baib;

const   fi='';
        fo='';

var     f,g:text;
        a,c:array[0..10,0..10]of longint;
        s1,s2,t1,t2,w1,w2,b1,b2:longint;

procedure enter;
var i,j,u:longint;
    ch,cc:char;
begin
assign(f,fi);assign(g,fo);
reset(f);rewrite(g);
   read(f,ch,u,cc);
   s1:=ord(ch)-ord('a')+1;
   t1:=u;
   read(f,ch,u,cc);
   s2:=ord(ch)-ord('a')+1;
   t2:=u;
   read(f,ch,u,cc);
   w1:=ord(ch)-ord('a')+1;
   w2:=u;
   read(f,ch,u);
   b1:=ord(ch)-ord('a')+1;
   b2:=u;
end;

procedure process;
var i,j,u,v:longint;
begin
fillchar(a,sizeof(a),255);
fillchar(c,sizeof(c),0);
for i:=1 to 8 do
 for j:=1 to 8 do a[i,j]:=0;
a[w1,w2]:=-1;
c[b1,b2]:=2;
for i:=-1 to 1 do
 for j:=-1 to 1 do
 if a[b1+i,b2+j]<>-1 then
 begin
  c[b1+i,b2+j]:=2;
 end;
for i:=-1 to 1 do
 for j:=-1 to 1 do
  c[w1+i,w2+j]:=1;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  dec(u);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  inc(u);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  dec(v);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  inc(v);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  dec(u);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  inc(u);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  dec(v);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  inc(v);
  c[u,v]:=1;
 end;
 u:=0;
for i:=1 to 8 do
 for j:=1 to 8 do
  if c[i,j]=2 then u:=1;
if u=0 then writeln(g,'CHECKMATE')
else writeln(g,'OTHER');
end;

BEgin
    enter;
    process;
    close(g);
end.

type res= record
          x,y:longint;
          end;
var n,i,j,k,code:integer;
    f1,f2,f3,f4:boolean;
    s:string;
    kor:array[1..4]Of res;
Function BK(x1,y1,x2,y2:longint):boolean;
Begin
     if (abs(x1-x2)<=1)and(abs(y1-y2)<=1)
     then bk:=true
     else bk:=false;
End;
Function WK(x1,y1,x2,y2,x3,y3:longint):boolean;
Begin
    if (x1=x2)and(y1=y2)
    then wk:=false
    else
    if (x1=x2) then
    begin
    if (x1=x3) then
    if (y3<y1)and(y2<y3)
     or(y3>y1)and(y2>y3)
     then wk:=false
     else wk:=true;

    end
    else wk:=false;
End;
Function Fi(x,y:longint):boolean;
Begin
     if (x<=0)or(y<=0)
      or(y>=9)or(x>=9)
     then fi:=true
     else
     begin
     if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)
     or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)
     or bk(x,y,kor[3].x,kor[3].y)
     then fi:=true
     else fi:=false;
     end;
End;
Begin
    readln(s);
    j:=1;
    For i:=1 to 11 do
    begin
         val(s[i],k,code);
         if k>0 then kor[j].y:=k;
         if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;
         if (i mod 3)=0 then inc(j);
    end;
    if fi(kor[4].x,kor[4].y)
    then begin
              if fi(kor[4].x+1,kor[4].y)and
                 fi(kor[4].x+1,kor[4].y+1)and
                 fi(kor[4].x,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y)and
                 fi(kor[4].x-1,kor[4].y-1)and
                 fi(kor[4].x,kor[4].y-1)and
                 fi(kor[4].x+1,kor[4].y-1)
                 then writeln('CHECKMATE')
                 else writeln('OTHER')
         end
     else writeln('OTHER');
End.

program     CFR41_A;
uses
    math;

const
    nfin=   '';
    nfout=  '';
    maxn=   30;
    vt:array[1..8,1..2] of longint=((0, 1), (1, 0), (-1, 0), (0, -1), (1, -1), (1, 1), (-1, -1), (-1, 1));

var
    d1, c1, d2, c2, d3, c3, d4, c4, u, v, i: longint;
    k1, k2, k3: char;
    fin, fout:  text;

function check(u, v: longint): boolean;
begin
    if ((u<>d1) and (v=c1))then begin
        if c3<>c1 then begin
            check:=true;
            exit;
        end;

        if ((d3<min(d1, u)) or (d3>max(u, d1))) then begin
            check:=true;
            exit;
        end;
    end;

    if ((u=d1) and (v<>c1))then begin
        if d3<>d1 then begin
            check:=(true);
            exit;
        end;
        if ((c3<min(c1, v)) or (c3>max(v, c1))) then begin
            check:=true;
            exit;
        end;
    end;

     if ((u<>d2) and (v=c2))then begin
        if c3<>c2 then begin
            check:=true;
            exit;
        end;

        if ((d3<min(d2, u)) or (d3>max(u, d2))) then begin
            check:=true;
            exit;
        end;
     end;

    if ((u=d2) and (v<>c2))then begin
        if d3<>d2 then begin
            check:=true;
            exit;
        end;
        if ((c3<min(c2, v)) or (c3>max(v, c2))) then begin
            check:=true;
            exit;
        end;
    end;

    if (abs(u-d3)<=1) and (abs(v-c3)<=1) then begin
        check:=true;
        exit;
        end;
    check:=false;
end;

begin
    assign(fin, nfin); reset(fin);
    assign(fout, nfout); rewrite(fout);
    read(fin, k1, k2);
    d1:=ord(k1) - ord('a') + 1;
    c1:=ord(k2) - ord('0');

    read(fin, k3, k1, k2);
    d2:=ord(k1) - ord('a') + 1;
    c2:=ord(k2) - ord('0');

    read(fin,k3, k1, k2);
    d3:=ord(k1) - ord('a') + 1;
    c3:=ord(k2) - ord('0');

    read(fin,k3, k1, k2);
    d4:=ord(k1) - ord('a') + 1;
    c4:=ord(k2) - ord('0');

    if not check(d4, c4) then begin
        writeln(fout, 'OTHER');
        close(fout);
        close(fin);
        halt;
    end;

    for i:=1 to 8 do begin
        u:=d4+vt[i, 1];
        v:=c4+vt[i, 2];
        if (0<v) and (v<=8) and (0<u) and (u<=8) then begin
            if not check(u, v) then begin
                writeln(fout, 'OTHER');
                close(fout);
                close(fin);
                halt;
            end;
        end;
    end;

    writeln(fout, 'CHECKMATE');
    close(fout);
    close(fin);
end.

program CF_GameOfChessUnfinished;
var
        x,y,p:char;
        a,b,c,d,e,f,g,h,i,j:integer;
        mark:array[0..9,0..9] of boolean;
        ima,t:boolean;
begin
        for i:=0 to 9 do
          for j:=0 to 9 do mark[i,j]:=true;
        for i:=1 to 8 do
          for j:=1 to 8 do mark[i,j]:=false;
        read(x,y,p);
        a:=ord(x)-96;
        b:=ord(y)-48;
        read(x,y,p);
        c:=ord(x)-96;
        d:=ord(y)-48;
        read(x,y,p);
        e:=ord(x)-96;
        f:=ord(y)-48;
        read(x,y);
        readln;
        g:=ord(x)-96;
        h:=ord(y)-48;
        //t:=mark[a,b];
        for i:=a+1 to 8 do
          if (i=e) and (b=f) then break
          else mark[i,b]:=true;
        for i:=a-1 downto 1 do
          if (i=e) and (b=f) then break
          else mark[i,b]:=true;
        for i:=b+1 to 8 do
          if (a=e) and (i=f) then break
          else mark[a,i]:=true;
        for i:=b-1 downto 1 do
          if (a=e) and (i=f) then break
          else mark[a,i]:=true;

        for i:=c+1 to 8 do
          if (i=e) and (d=f) then break
          else mark[i,d]:=true;
        for i:=c-1 downto 1 do
          if (i=e) and (d=f) then break
          else mark[i,d]:=true;
        for i:=d+1 to 8 do
          if (c=e) and (i=f) then break
          else mark[c,i]:=true;
        for i:=d-1 downto 1 do
          if (c=e) and (i=f) then break
          else mark[c,i]:=true;

        mark[e,f+1]:=true;
        mark[e,f-1]:=true;
        mark[e-1,f]:=true;
        mark[e+1,f]:=true;
        mark[e+1,f+1]:=true;
        mark[e+1,f-1]:=true;
        mark[e-1,f+1]:=true;
        mark[e-1,f-1]:=true;

        ima:=not(mark[g,h+1]) or not(mark[g,h-1]) or not(mark[g+1,h]) or not(mark[g-1,h]) or not(mark[g+1,h+1]) or not(mark[g+1,h-1]) or not(mark[g-1,h+1]) or not(mark[g-1,h-1]);
        if not(ima) and mark[g,h] then writeln('CHECKMATE')
        else writeln('OTHER');
end.

var
 a,b:array[0..9,0..9] of char;
  x,y,i,j:longint;
   answer:boolean;
    s:string;

procedure proverka(var rez:boolean);
var i,j,x,y:longint;
 begin
  rez:=true;
   for i:=1 to 8 do
    for j:=1 to 8 do
     if b[i,j]<>'.'
      then
       begin
        if b[i,j]='L'
         then
          begin
           x:=i; y:=j;
            while (b[x,y]<>'#') and (b[x,y]<>'W') do
             begin
              if b[x,y]='B' then exit;
               inc(x);
             end;
           x:=i; y:=j;
            while (b[x,y]<>'#') and (b[x,y]<>'W') do
             begin
              if b[x,y]='B' then exit;
               dec(x);
             end;
           x:=i; y:=j;
            while (b[x,y]<>'#') and (b[x,y]<>'W') do
             begin
              if b[x,y]='B' then exit;
               inc(y);
             end;
           x:=i; y:=j;
            while (b[x,y]<>'#') and (b[x,y]<>'W') do
             begin
              if b[x,y]='B' then exit;
               dec(y);
             end;
          end;
        if b[i,j]='W'
         then
          begin
           if (b[i-1,j-1]='B') or (b[i-1,j]='B') or (b[i-1,j+1]='B') or (b[i,j-1]='B') or (b[i,j+1]='B') or (b[i+1,j-1]='B') or (b[i+1,j]='B') or (b[i+1,j+1]='B')
            then
             begin
              exit;
             end;
          end;
       end;
  rez:=false;
 end;

procedure untilprogram;
var i,j:longint;
 begin
  for i:=1 to 8 do
   for j:=1 to 8 do
  a[i,j]:='.';
  for i:=0 to 9 do
   begin
    a[i,0]:='#';
     a[i,9]:='#';
     a[0,i]:='#';
    a[9,i]:='#';
   end;
 end;

begin

  untilprogram;
   readln(s);
    x:=ord(s[1])-96;
     y:=9-(ord(s[2])-48);
    a[x,y]:='L';
    x:=ord(s[4])-96;
     y:=9-(ord(s[5])-48);
    a[x,y]:='L';
    x:=ord(s[7])-96;
     y:=9-(ord(s[8])-48);
    a[x,y]:='W';
    x:=ord(s[10])-96;
     y:=9-(ord(s[11])-48);
    a[x,y]:='B';
   b:=a;
   proverka(answer);
    if answer = false
     then
      begin
       writeln('OTHER');
        halt;
      end
     else
      begin
       for i:=-1 to 1 do
        for j:=-1 to 1 do
         if not((i=0) and (j=0)) and (x+i>=1) and (x+i<=8) and (y+j>=1) and (y+j<=8)
          then
           begin
            b:=a;
             b[x,y]:='.'; b[x+i,y+j]:='B';
              proverka(answer);
             if answer = false
              then
               begin
                writeln('OTHER');
                 halt;
               end;
           end;
      end;
  writeln('CHECKMATE');

end.

Program z42b;
type byte=integer;
const xx:array[1..8]of shortint=(-1,-1,0,1,1,1,0,-1);
	yy:array[1..8]of shortint=(0,1,1,1,0,-1,-1,-1);
var a,c:array[0..9,0..9]of byte;
	b:array[1..2,1..4]of byte;
	x,y,i,x1,y1,j:byte;
    cc:char;
begin
	j:=1;
	for i:=2 to 3 do
    begin
    	read(cc);
        x:=ord(cc)-ord('a')+1;
        read(y);
        c[y,x]:=i;
        b[1,j]:=x;
        b[2,j]:=y;
        inc(j);
        read(cc);
        read(cc);
        x1:=ord(cc)-ord('a')+1;
        read(y1);
        c[y1,x1]:=2;
        read(cc);
        b[1,j]:=x1;
        b[2,j]:=y1;
        inc(j);
    end;
    for i:=0 to 9 do
    begin
    	a[i,0]:=1;
        a[i,9]:=1;
        a[0,i]:=1;
        a[9,i]:=1;
    end;
    for i:=1 to 2 do
    begin
    	j:=b[1,i]+1;
        while (j<=8)and(c[b[2,i],j]<3) do
        begin
            a[b[2,i],j]:=1;
            inc(j);
        end;
        a[b[2,i],j]:=1;
        j:=b[1,i]-1;
        while (j>0)and(c[b[2,i],j]<3) do
        begin
        	a[b[2,i],j]:=1;
            dec(j);
        end;
        a[b[2,i],j]:=1;
        j:=b[2,i]+1;
        while (j<=8)and(c[j,b[1,i]]<3) do
        begin
        	a[j,b[1,i]]:=1;
            inc(j);
        end;
        a[j,b[1,i]]:=1;
        j:=b[2,i]-1;
        while (j>0)and(c[j,b[1,i]]<3) do
        begin
        	a[j,b[1,i]]:=1;
            dec(j);
        end;
        a[j,b[1,i]]:=1;
    end;
    for i:=1 to 8 do
    	a[y+yy[i],x+xx[i]]:=1;
    if a[y1,x1]=1
    then
    begin
    	for i:=1 to 8 do
    	  	if a[y1+yy[i],x1+xx[i]]=0 then begin write('OTHER');halt;end;
        write('CHECKMATE');
    end
    else write('OTHER');
end.

program shablon;
{$O+ R-  Q-}
uses
 SysUtils;
type Tpoint=record
       x,y:longint;
     end;

const dx:array[0..8] of longint=(0,-1,0,+1,+1,+1,0,-1,-1);
      dy:array[0..8] of longint=(0,-1,-1,-1,0,+1,+1,+1,0);

var b:array[0..9,0..9] of boolean;
    i,x,y:longint;
    a:array[1..4] of tpoint;
    c:char;
    flag:boolean;
procedure postout {inline};
begin

 close(input);
 close(output);
 halt(0);
end;

procedure preinit {inline};
begin
 assign(input,'input.txt');
 assign(output,'output.txt');
 reset(input);
 rewrite(output);

end;

function check(i,x,y:longint):boolean;
var j:longint;
begin
 for j:=1 to 3 do
  if i<>j
   then
    begin
     if (x=a[j].x)and(y=a[j].y)
      then
       begin
        result:=false;
        exit;
       end;
    end;
 result:=true;
end;

begin
// preinit;
 fillchar(b,sizeof(b),0);
 for i:=0 to 9 do
  begin
   b[i,0]:=true;
   b[i,9]:=true;
   b[0,i]:=true;
   b[9,i]:=true;
  end;
 for i:=1 to 4 do
  begin
   read(c);
   a[i].x:=ord(c)-ord('a')+1;
   read(c);
   a[i].y:=strtoint(c);
   read(c);
  end;
 for i:=1 to 2 do begin
 x:=a[i].x;
 y:=a[i].y;
 flag:=b[x,y];
 dec(y);
 while (y>0)and(check(i,x,y)) do
  begin
   b[x,y]:=true;
   dec(y);
  end;
 if (y>0)and not (check(i,x,y))
  then
   b[x,y]:=true;
 x:=a[i].x;
 y:=a[i].y;
 inc(y);
 while (y<9)and(check(i,x,y)) do
  begin
   b[x,y]:=true;
   inc(y);
  end;
 if (y<9)and not (check(i,x,y))
  then
   b[x,y]:=true;
 x:=a[i].x;
 y:=a[i].y;
 dec(x);
 while (x>0)and(check(i,x,y)) do
  begin
   b[x,y]:=true;
   dec(x);
  end;
 if (x>0)and not (check(i,x,y))
  then
   b[x,y]:=true;
 x:=a[i].x;
 y:=a[i].y;
 inc(x);
 while (x<9)and(check(i,x,y)) do
  begin
   b[x,y]:=true;
   inc(x);
  end;
 if (x<9)and not (check(i,x,y))
  then
   b[x,y]:=true;
 b[a[i].x,a[i].y]:=flag;
 end;
 for i:=1 to 8 do
  begin
   b[a[3].x+dx[i],a[3].y+dy[i]]:=true;
  end;
 for i:=0 to 8 do
  begin
   if not (b[a[4].x+dx[i],a[4].y+dy[i]])
    then
     begin
      writeln('OTHER');
      halt(0);
     end;
  end;
 writeln('CHECKMATE');
// postout;
end.

var a,b:array[0..9,0..9]of byte;
    n:array[1..2,1..4]of byte;
    i,x,y,j,k:longint;
    ch:char;
    by:byte;
    s:string;
begin
 fillchar(a,sizeof(a),0);
 fillchar(b,sizeof(b),0);
 for i:=0 to 9 do begin
  a[0,i]:=1; a[i,0]:=1;
  a[9,i]:=1; a[i,9]:=1;
 end;
 for i:=1 to 3 do begin
  read(ch);read(by);
  n[1,i]:=ord(ch)-ord('a')+1;
  n[2,i]:=by;
  read(ch);
  if i<3 then b[n[1,i],n[2,i]]:=1 else b[n[1,i],n[2,i]]:=2;
 end;
  x:=n[1,3]; y:=n[2,3];
   for j:=x-1 to x+1 do
    for k:=y-1 to y+1 do
     inc(a[j,k]);

  for i:=1 to 2 do begin
   x:=n[1,i]; y:=n[2,i];
   j:=x; k:=y;
   repeat
    inc(a[j+1,k]);
    j:=j+1;
   until (j=9)or(b[j,k]>0);
   j:=x;
   repeat
    inc(a[j-1,k]);
    j:=j-1;
   until (j=0)or(b[j,k]>0);
   j:=x;
   repeat
    inc(a[j,k+1]);
    k:=k+1;
   until (k=9)or(b[j,k]>0);
   k:=y;
   repeat
    inc(a[j,k-1]);
    k:=k-1;
   until (k=0)or(b[j,k]>0);
  end;

  read(ch);read(by);
  x:=ord(ch)-ord('a')+1;
  y:=by;
  s:='CHECKMATE';
  for i:=x-1 to x+1 do
   for j:=y-1 to y+1 do begin
    if (a[i,j]=0) then s:='OTHER';
    end;
  writeln(s);

end.

program b41;
type figure=record
     x,y:byte;
     end;
var p:array [0..9,0..9] of byte;
    l1,l2,k1,k2:figure;
    l:string;
    r:boolean;
    I,j:integer;
procedure print;
          var m,n:integer;
          begin
               for n:=9 downto 0 do begin
                   for m:=0 to 9 do write(p[m,n]:2);
                   writeln;
               end;
          end;
begin
     readln(l);
     l1.x:=ord(l[1])-96;
     l1.y:=ord(l[2])-48;
     l2.x:=ord(l[4])-96;
     l2.y:=ord(l[5])-48;
     k1.x:=ord(l[7])-96;
     k1.y:=ord(l[8])-48;
     k2.x:=ord(l[10])-96;
     k2.y:=ord(l[11])-48;
     for i:=0 to 9 do begin
         p[0,i]:=1;
         p[i,0]:=1;
         p[9,i]:=1;
         p[i,9]:=1;
     end;
     for i:=l1.x+1 to 8 do if (k1.x=i)and(k1.y=l1.y) then break else p[i,l1.y]:=1;
     for i:=l1.x-1 downto 1 do if (k1.x=i)and(k1.y=l1.y) then break else p[i,l1.y]:=1;
     for i:=l1.y+1 to 8 do if (k1.x=l1.x)and(k1.y=i) then break else p[l1.x,i]:=1;
     for i:=l1.y-1 downto 1 do if (k1.x=l1.x)and(k1.y=i) then break else p[l1.x,i]:=1;

     for i:=l2.x+1 to 8 do if (k1.x=i)and(k1.y=l2.y) then break else p[i,l2.y]:=1;
     for i:=l2.x-1 downto 1 do if (k1.x=i)and(k1.y=l2.y) then break else p[i,l2.y]:=1;
     for i:=l2.y+1 to 8 do if (k1.x=l2.x)and(k1.y=i) then break else p[l2.x,i]:=1;
     for i:=l2.y-1 downto 1 do if (k1.x=l2.x)and(k1.y=i) then break else p[l2.x,i]:=1;

     for i:=k1.x-1 to k1.x+1 do
         for j:=k1.y-1 to k1.y+1 do
             p[i,j]:=1;
     for i:=k2.x-1 to k2.x+1 do
         for j:=k2.y-1 to k2.y+1 do
             if p[i,j]=0 then r:=true;

     if r=true then writeln ('OTHER') else writeln ('CHECKMATE');
end.

program Unit1;
{$APPTYPE CONSOLE}
var s:string;
    z,i,j:integer;
    a,b:array[1..4]of integer;
    q:array[0..9,0..9]of integer;
begin
{  assign(input,'input.txt');
  assign(output,'output.txt');
  reset(input);
  rewrite(output);}
  read(s);
  a[1]:=ord(s[1])-ord('a')+1;
  b[1]:=ord(s[2])-ord('0');
  a[2]:=ord(s[4])-ord('a')+1;
  b[2]:=ord(s[5])-ord('0');
  a[3]:=ord(s[7])-ord('a')+1;
  b[3]:=ord(s[8])-ord('0');
  a[4]:=ord(s[10])-ord('a')+1;
  b[4]:=ord(s[11])-ord('0');
  for i:=0 to 9 do begin
    q[i,0]:=1;
    q[i,9]:=1;
    q[0,i]:=1;
    q[9,i]:=1;
  end;
  for z:=1 to 2 do begin
    for i:=a[z] downto 1 do begin
      if (i=a[z])then
        continue;
      q[i,b[z]]:=1;
      if (b[z]=b[3-z])and(i=a[3-z])then
        break;
      if (b[z]=b[3])and(i=a[3])then
        break;
    end;
    for i:=a[z] to 8 do begin
      if (i=a[z])then
        continue;
      q[i,b[z]]:=1;
      if (b[z]=b[3-z])and(i=a[3-z])then
        break;
      if (b[z]=b[3])and(i=a[3])then
        break;
    end;
    for i:=b[z] downto 1 do begin
      if (i=b[z])then
        continue;
      q[a[z],i]:=1;
      if (a[z]=a[3-z])and(i=b[3-z])then
        break;
      if (a[z]=a[3])and(i=b[3])then
        break;
    end;
    for i:=b[z] to 8 do begin
      if (i=b[z])then
        continue;
      q[a[z],i]:=1;
      if (a[z]=a[3-z])and(i=b[3-z])then
        break;
      if (a[z]=a[3])and(i=b[3])then
        break;
    end;
  end;
  for i:=-1 to 1 do
    for j:=-1 to 1 do begin
      if (i=0)and(j=0)then continue;
      q[a[3]+i,b[3]+j]:=1;
    end;
  for i:=-1 to 1 do
    for j:=-1 to 1 do
      if q[a[4]+i,b[4]+j]=0 then begin
        writeln('OTHER');
        halt(0);
      end;
  writeln('CHECKMATE');
end.

{$apptype console}

type Tpos = record x, y : integer; end;

procedure readpos( var p : TPos );
var ch :char;
begin
  read(ch );
  while not (ch in ['a'..'h']) do read( ch );
  p.y := ord(ch) - ord('a' ) + 1;
  read(ch);
  p.x := ord(ch) - ord('0');
end;

var l1,l2, wk : TPos;

function inner( x,a,b : integer ) : boolean;
var t : integer;
begin
  if a > b then begin t := a; a:=b; b := t; end;
  result := (x>a) and (x<b );
end;

function lb( const lp :Tpos; xx, yy : integer ) : boolean;
begin
   result := false;
   if( lp.x = xx) and (lp.y=yy) then exit;
{}
   if(lp.x = xx ) then begin
      if not (inner( wk.y, yy, lp.y ) and (wk.x=xx)) then begin
         result := true;
         exit;
      end;
   end;
{}
   if(lp.y = yy ) then begin
      if not (inner( wk.x, xx, lp.x )and(wk.y=yy)) then begin
         result := true;
         exit;
      end;
   end;
end;

function beaten( xx, yy : integer ): boolean;
begin
   result := false;
   if lb(l1,xx,yy) or lb(l2,xx,yy) then begin
      result := true;
      exit;
   end;
   if (xx<>wk.x) or( yy<>wk.y) then begin
      if (abs(wk.x - xx)<=1) and (abs(wk.y-yy) <= 1) then begin
         result := true;
         exit;
      end;
   end;
{   writeln( xx, ' ',yy );}
end;

const v : array [1..8, 1..2] of integer =
((1,0),(-1,0),(0,1),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1));
var bk  : TPos;
    i, xx,yy : integer;
begin
{  reset( input, 'in.txt' );}
{}
   ReadPos( l1 );
   ReadPos( l2 );
   ReadPos( wk );
   ReadPos( bk );
{}
   if not beaten( bk.x, bk.y ) then begin
         writeln( 'OTHER' );
         exit;
   end;
   for i := 1 to 9 do begin
      xx := bk.x + v[i,1];
      yy := bk.y + v[i,2];
      if (xx>=1) and (xx<=8) and ( yy>=1) and (yy<=8) then begin
        if not beaten( xx, yy ) then begin
           writeln( 'OTHER' );
           exit;
        end;
      end;
   end;
   writeln( 'CHECKMATE');
end.

 {uses crt;}
 const nn=50;
    type mas=array [0..nn] of longint;
    var i1,j1,ot,n,i,j,k,il,p,imin,m,lengtha,shag:longint;
    l1,l2,wk,bk,nk:mas;
   s:real;
       a,b,pr:mas;
       ll1,ll2,wwk,bbk,ll3:char;
      boypol,boy:boolean;

  function boyl1(i,j:longint):boolean; var bb1,bb2:boolean;
begin
 bb1:=false;
 if l1[1]=i then begin bb1:=true;
 if wk[1]=i then if ((wk[2]-l1[2])*(wk[2]-j)<0)
 then begin bb1:=false; {write('aaa');} end;
 end;
{ writeln('bb1',bb1);}

 bb2:=false;
 if l1[2]=j then begin bb2:=true;
 if wk[2]=j then if ((wk[1]-l1[1])*(wk[1]-i)<0)
 then begin bb2:=false; {write('bbb');} end;
 end;

{ writeln('bb2',bb2); }

boyl1:=bb1 or bb2;  if (i=l1[1])and(j=l1[2]) then boyl1:=false;

end;

  function boyl2(i,j:longint):boolean; var bb1,bb2:boolean;
begin
 bb1:=false;
 if l2[1]=i then begin bb1:=true;
 if wk[1]=i then if ((wk[2]-l2[2])*(wk[2]-j)<0) then bb1:=false; end;
{ writeln('rrr',bb1); }

 bb2:=false;
 if l2[2]=j then begin bb2:=true;
 if wk[2]=j then if ((wk[1]-l2[1])*(wk[1]-i)<0) then bb2:=false; end;

{ writeln('www',bb2); }

boyl2:=bb1 or bb2;

if (i=l2[1])and(j=l2[2]) then boyl2:=false;

end;

 function boyk(i,j:longint):boolean; var bb1,bb2:boolean;
  begin
       bb1:=false; if (abs(i-wk[1])<=1) and(abs(j-wk[2])<=1)  then bb1:=true;
    boyk:=bb1;
  end;

     begin  {  clrscr;
     assign(input,'input.txt'); reset (input); }
         {  assign(output,'digitsum.out'); rewrite (output); }
       read(ll1);read(ll2);read(ll3);
       l1[1]:=ord(ll1)-96;
       l1[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       l2[1]:=ord(ll1)-96;
       l2[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       wk[1]:=ord(ll1)-96;
       wk[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       bk[1]:=ord(ll1)-96;
       bk[2]:=ord(ll2)-48;

      { write(l1[1],' ',l1[2],' ',l2[1],' ',l2[2],' ',wk[1],' ',wk[2],' ',bk[1],' ',bk[2],' ');
        }
        boy:=true;
  for i:=-1 to 1 do
  for j:=-1 to 1 do
  if ((bk[1]+i)>=1)and((bk[1]+i)<=8)and((bk[2]+j)>=1)and((bk[2]+j)<=8) then
     begin  boypol:=false;
     nk[1]:=bk[1]+i; nk[2]:=bk[2]+j; i1:=nk[1];j1:=nk[2];
       if boyl1(i1,j1)or boyl2(i1,j1) or boyk(i1,j1)  then boypol:=true;
       if not boypol then boy:=false;

     end;

 {    writeln;
     for i:=1 to 8 do
     begin for j:=1 to 8 do if boyl1(i,j)
     then write('+') else write('-');writeln; end;
  }
  { writeln(boyl1(1,4)); }

  if boy then write('CHECKMATE') else write('OTHER');

           end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
function sr(a,b,c:byte): boolean ;
var d:byte;
begin
 if b> c then begin d:=c; c:=b; b:=d;end;
 if (b<a) and (a< c) then result:=true else result:=false;
end;

var i,f,L1b,L1k,l2b,l2k,kbb,kcb,kbk,kck,k,d : integer ;
 a: string ;

begin
//assign(input,'input.txt')  ;
//assign(output,'output.txt') ;

readln(a) ;
f:=ord ('a');
l1b:=ord (a[1])-f+1 ;
l1k:= StrToInt (a[2]);

l2b:=ord (a[4])-f+1 ;
l2k:= StrToInt (a[5])  ;

kbb:=ord (a[7])-f+1 ;
kbk:= StrToInt (a[8]) ;

kcb:=ord (a[10])-f+1 ;
kck:= StrToInt (a[11]);

d:=0 ;
for i:=kcb-1 to kcb+1 do
   for k:=kck-1 to kck+1 do
    if (k<1) or (k>8)or (i>8) or (i<1) then
      inc(d)
    else
      if ((i=l1b) and (k<>l1k)and not(sr(kbk,k,l1k)and (kbb=i))) or
      ((i<>l1b) and (k=l1k) and not(sr(kbb,i,l1b)and (kbk=k)))or
      ((i=l2b) and (k<>l2k) and not(sr(kbk,k,l2k)and (kbb=i))) or
      ((i<>l2b) and (k=l2k) and not (sr(kbb,i,l2b)and (kbk=k)))or
      ((abs(kbb-i)<=1) and (abs(kbk-k)<=1)) then
       inc(d) ;
if d=9 then
 writeln ('CHECKMATE')
else
 writeln ('OTHER');

// readln;
end.

program ProblemB;

{$APPTYPE CONSOLE}

var map : array [0..9, 0..9] of boolean;
    c : array [1..4, 1..2] of integer;
    ch : char;
    i, x, y, j : integer;
    ans : boolean;

begin
  for i := 1 to 4 do
  begin
    read(ch);
    c[i, 1] := ord(ch) - 96;
    read(ch);
    c[i, 2] := ord(ch) - 48;
    read(ch);
  end;

  for i := 0 to 9 do
    for j := 0 to 9 do
      map[i, j] := false;

  for i := 0 to 9 do
  begin
    map[i, 0] := true;
    map[i, 9] := true;
    map[0, i] := true;
    map[9, i] := true;
  end;

  x := c[1, 1];
  y := c[1, 2];
  for i := x + 1 to 8 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := x - 1 downto 1 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := y + 1 to 8 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;
  for i := y - 1 downto 1 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;

  //-------------------------------

  x := c[2, 1];
  y := c[2, 2];
  for i := x + 1 to 8 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := x - 1 downto 1 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := y + 1 to 8 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;
  for i := y - 1 downto 1 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;

  map[c[3, 2], c[3, 1]] := true;
  x := c[3, 1];
  y := c[3, 2];
  map[y + 1, x] := true;
  map[y - 1, x] := true;
  map[y, x + 1] := true;
  map[y, x - 1] := true;
  map[y + 1, x + 1] := true;
  map[y + 1, x - 1] := true;
  map[y - 1, x + 1] := true;
  map[y - 1, x - 1] := true;

  x := c[4, 1];
  y := c[4, 2];

  if ((not(map[y, x])) or (not(map[y + 1, x])) or (not(map[y - 1, x])) or (not(map[y, x + 1])) or (not(map[y, x - 1]))) or (not(map[y + 1, x + 1])) or (not(map[y + 1, x - 1])) or (not(map[y - 1, x + 1])) or (not(map[y - 1, x - 1])) then writeln('OTHER')
  else writeln('CHECKMATE');

  readln;
  readln;
end.

program myw;

{$APPTYPE CONSOLE}

uses
  SysUtils;

  type Point = record
    x : longint;
    y : longint;
   end;

var i,j : longint;  s : char;
    a,b,c,d : point;
    mas : array[-10..20,-10..20] of longint;
begin
   read(s);
   a.x:=ord(s)-ord('a')+1;
   read(s);
   a.y:=ord(s)-ord('0');
   read(s);
   read(s);
   b.x:=ord(s)-ord('a')+1;
   read(s);
   b.y:=ord(s)-ord('0');
   read(s);
   read(s);
   c.x:=ord(s)-ord('a')+1;
   read(s);
   c.y:=ord(s)-ord('0');
   read(s);
   read(s);
   d.x:=ord(s)-ord('a')+1;
   read(s);
   d.y:=ord(s)-ord('0');
   for i:=1 to 8 do
    for j:=1 to 8 do
      mas[i,j]:=0;

   for i:=a.x to 8 do
     if (i<>c.x) or (a.y<>c.y) then
       inc(mas[i,a.y]) else break;
   for i:=a.x downto -8 do
     if (i<>c.x) or (a.y<>c.y) then
       inc(mas[i,a.y]) else break;
   for i:=a.y to 8 do
     if (a.x<>c.x) or (i<>c.y) then
       inc(mas[a.x,i]) else break;
   for i:=a.y downto -8 do
     if (a.x<>c.x) or (i<>c.y) then
       inc(mas[a.x,i]) else break;

   dec(mas[a.x,a.y],4);

   for i:=b.x to 8 do
     if (i<>c.x) or (b.y<>c.y) then
       inc(mas[i,b.y]) else break;
   for i:=b.x downto -8 do
     if (i<>c.x) or (b.y<>c.y) then
       inc(mas[i,b.y]) else break;
   for i:=b.y to 8 do
     if (b.x<>c.x) or (i<>c.y) then
       inc(mas[b.x,i]) else break;
   for i:=b.y downto -8 do
     if (b.x<>c.x) or (i<>c.y) then
       inc(mas[b.x,i]) else break;

    dec(mas[b.x,b.y],4);

    {
          for i:=1 to 8 do
     begin
     writeln;
     for j:=1 to 8 do
       write(mas[i,j]);
     end;

   readln(i);
     }

  //  dec(mas[a.x,a.y],2);
 //   dec(mas[b.x,b.y],2);
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          inc(mas[c.x+i,c.y+j]);
        end;
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)
             and (mas[d.x+i,d.y+j]=0) then begin writeln('OTHER'); exit; end;
        end;

     writeln('CHECKMATE');

end.

program shablon;

{$APPTYPE CONSOLE}
uses
  SysUtils;
type
    pt = record
        x,y:integer;
    end;
var
    l,l1,k,k1:pt;
    c:char;
function getc:pt;
var
    c:char;
begin
    read(c);
    result.x := ord(c) - ord('a') + 1;
    read(c);
    result.y := ord(c) - ord('0');
end;
function check(k1:pt):boolean;
var
    i,j:integer;
begin
    result := true;
    if (abs(k.x - k1.x) <=  1)  and (abs(k.y - k1.y) <= 1) then
        exit;
    i := k1.x;
    j := i;
    while true do
    begin
        if (l.x = i) and (l.y = k1.y) and (i <> k1.x) then
            exit;
        if (l.x = j) and (l.y = k1.y) and (j <> k1.x) then
            exit;
        if (l1.x = i) and (l1.y = k1.y) and (i <> k1.x) then
            exit;
        if (l1.x = j) and (l1.y = k1.y) and (j <> k1.x) then
            exit;

        if ((i = 8) and ( j = 1)) or ( ((i = k.x) and (k.y = k1.y) ) and ((j = k.x) and (k.y = k1.y))) or ( ((i = k.x) and (k.y = k1.y) ) and (j = 1)) or ( ((i = 8) ) and ((j = k.x) and (k.y = k1.y))) then
            break;
        if (i < 8) and (not ((i = k.x) and (k.y = k1.y))) then
            inc(i);
        if (j > 1) and (not ((j = k.x) and (k.y = k1.y)))then
            dec(j);
    end;
    i := k1.y;
    j := i;
    while true do
    begin
        if (l.y = i) and (l.x = k1.x) and (i <> k1.y) then
            exit;
        if (l.y = j) and (l.x = k1.x) and (j <> k1.y) then
            exit;
        if (l1.y = i) and (l1.x = k1.x) and (i <> k1.y) then
            exit;
        if (l1.y = j) and (l1.x = k1.x) and (j <> k1.y) then
            exit;
        if ((i = 8) and ( j = 1)) or (((i = k.y) and (k.x = k1.x) ) and ((j = k.y) and (k.x = k1.x))) then
            break;
        if  (((i = k.y) and (k.x = k1.x) ) and ((j = 1))) then
            break;
        if (i= 8 ) and ((j = k.y) and (k.x = k1.x)) then
            break;
        if (i < 8) and (not ((i = k.y) and (k.x = k1.x))) then
            inc(i);
        if (j > 1) and (not ((j = k.y) and (k.x = k1.x)))then
            dec(j);
    end;
    result := false;
end;
function pos:boolean;
var
    i,j:integer;
    p:pt;
begin
    result := true;
    for i := -1 to 1 do
        for j := -1 to 1 do
        begin
            if (i =0) and (j = 0) then
                continue;
            if (k1.x + i < 1) or (k1.x + i > 8) or (k1.y + j < 1) or (k1.y + j > 8) then
                continue;
            p.x := k1.x + i;
            p.y := k1.y + j;
           if  not (check(p)) then
                exit;
        end;
    result := false;
end;
begin
//    assign(input,'input.txt');reset(input);
//    assign(output,'output.txt');rewrite(output);
    l := getc;
    read(c);
    l1 := getc;
    read(c);
    k := getc;
    read(c);
    k1 := getc;

    if check(k1) then
    begin
        if pos then
            writeln('OTHER')
        else
            writeln('CHECKMATE');
    end
    else
        writeln('OTHER');
//    close(input);
//    close(output);
end.

program ProblemB;

{$APPTYPE CONSOLE}

uses
  SysUtils,Math;
type
  pos=record x,y:byte; end;
const
  king:array[1..8,1..2] of longint=((1,1), (1,0), (1,-1), (0,1), (0,-1), (-1,1), (-1,0), (-1,-1));
var
  l1,l2,bk,wk:pos;
  cur:pos;
  i,j:longint;
  bin,c1,c2,c3,c4:char;
  a:array[-2..10,-2..10] of byte;
  free:boolean;
function Num(c:char):byte;
begin
  Num:=ord(c)-ord('a')+1;
end;

begin
  //assign(Input,'in.txt'); assign(Output,'out.txt');
  read(c1,l1.y,bin,c2,l2.y,bin,c3,wk.y,bin,c4,bk.y);
  l1.x:=Num(c1);
  l2.x:=Num(c2);
  wk.x:=Num(c3);
  bk.x:=Num(c4);
  for i:=-2 to 10 do
    for j:=-2 to 10 do
      a[i][j]:=0;
  a[l1.x][l1.y]:=0;
  a[l2.x][l2.y]:=0;
  a[wk.x][wk.y]:=1;
  a[bk.x][bk.y]:=0;
  for i:=1 to 8 do
    inc(a[wk.x+king[i][1]][wk.y+king[i][2]],2);

  //////////////////////l1
  //up
  cur.x:=l1.x;
  cur.y:=l1.y+1;
  while (cur.y<=8) and ((l2.x<>cur.x) or (l2.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin
    inc(a[cur.x][cur.y]);
    inc(cur.y);
  end;
  if (l2.x=cur.x) and (l2.y=cur.y) then begin
    inc(a[l2.x][l2.y]);
  end;
  //down
  cur.x:=l1.x;
  cur.y:=l1.y-1;
  while (cur.y>=1) and ((l2.x<>cur.x) or (l2.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin
    inc(a[cur.x][cur.y]);
    dec(cur.y);
  end;
  if (l2.x=cur.x) and (l2.y=cur.y) then begin
    inc(a[l2.x][l2.y]);
  end;
  //left
  cur.x:=l1.x-1;
  cur.y:=l1.y;
  while (cur.x>=1) and ((l2.x<>cur.x) or (l2.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin
    inc(a[cur.x][cur.y]);
    dec(cur.x);
  end;
  if (l2.x=cur.x) and (l2.y=cur.y) then begin
    inc(a[l2.x][l2.y]);
  end;
  //right
  cur.x:=l1.x+1;
  cur.y:=l1.y;
  while (cur.x<=8) and ((l2.x<>cur.x) or (l2.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin
    inc(a[cur.x][cur.y]);
    inc(cur.x);
  end;
  if (l2.x=cur.x) and (l2.y=cur.y) then begin
    inc(a[l2.x][l2.y]);
  end;

  //////////////////////l2
  //up
  cur.x:=l2.x;
  cur.y:=l2.y+1;
  while (cur.y<=8) and ((l1.x<>cur.x) or (l1.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin
    inc(a[cur.x][cur.y]);
    inc(cur.y);
  end;
  if (l1.x=cur.x) and (l1.y=cur.y) then begin
    inc(a[l1.x][l1.y]);
  end;
  //down
  cur.x:=l2.x;
  cur.y:=l2.y-1;
  while (cur.y>=1) and ((l1.x<>cur.x) or (l1.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin
    inc(a[cur.x][cur.y]);
    dec(cur.y);
  end;
  if (l1.x=cur.x) and (l1.y=cur.y) then begin
    inc(a[l1.x][l1.y]);
  end;
  //left
  cur.x:=l2.x-1;
  cur.y:=l2.y;
  while (cur.x>=1) and ((l1.x<>cur.x) or (l1.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin
    inc(a[cur.x][cur.y]);
    dec(cur.x);
  end;
  if (l1.x=cur.x) and (l1.y=cur.y) then begin
    inc(a[l1.x][l1.y]);
  end;
  //right
  cur.x:=l2.x+1;
  cur.y:=l2.y;
  while (cur.x<=8) and ((l1.x<>cur.x) or (l1.y<>cur.y)) and ((wk.x<>cur.x) or (wk.y<>cur.y)) do begin
    inc(a[cur.x][cur.y]);
    inc(cur.x);
  end;
  if (l1.x=cur.x) and (l1.y=cur.y) then begin
    inc(a[l1.x][l1.y]);
  end;

  if a[bk.x,bk.y]=0 then begin
    write('OTHER');
    halt;
  end;

  for i:=-2 to 10 do
    for j:=-2 to 10 do
      if (i<1) or (i>8) or (j<1) or (j>8) then
        a[i][j]:=239;

  {for j:=8 downto 1 do begin
    for i:=1 to 8 do
      write(a[i][j],' ');
    writeln;
  end;
  }

  free:=false;
  for i:=1 to 8 do
    if a[bk.x+king[i][1]][bk.y+king[i][2]]<1 then
     free:=true;
  if free then begin
    writeln('OTHER');
    halt;
  end;
  free:=true;
  for i:=1 to 8 do
    if a[bk.x+king[i][1]][bk.y+king[i][2]]>1 then
     free:=false;
  if not(free) then begin
    write('CHECKMATE');
    halt;
  end;

  free:=false;
  for i:=1 to 8 do begin
    cur.x:=bk.x+king[i][1]; cur.y:=bk.y+king[i][2];
    if (((cur.x=l1.x) and (cur.y=l1.y)) and (a[l1.x][l1.y]=1)) or (((cur.x=l2.x) and (cur.y=l2.y)) and (a[l2.x][l2.y]=1)) then
      free:=true;
  end;

  if free then
    write('OTHER')
  else
    write('CHECKMATE');
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
const ch:array['a'..'h'] of byte=(1,2,3,4,5,6,7,8);
  Var a:array[0..9,0..9] of byte;
    i1,j1,i2,j2,i3,j3,ip,jp,i,j:Byte;
    f:boolean;
    st:string;
begin
for i:=0 to 9 do begin a[i,0]:=2;a[i,9]:=2; a[0,i]:=2;a[9,i]:=2 end;
Readln(st);
i1:=9-StrToInt(st[2]);
i2:=9-StrToInt(st[5]);
i3:=9-StrToInt(st[8]);
ip:=9-StrToInt(st[11]);
{j1:=ord(st[1])-ord('a')+1;
j2:=ord(st[4])-ord('a')+1;
j3:=ord(st[7])-ord('a')+1;
jp:=ord(st[10])-ord('a')+1;}
j1:=ch[st[1]];
j2:=ch[st[4]];
j3:=ch[st[7]];
jp:=ch[st[10]];

 for i:=i3-1  to i3+1 do
  for j:=j3-1  to j3+1 do inc(a[i,j]);
  a[i3,j3]:=2;

 i:=i1+1; j:=j1; while (a[i,j]<2) do  begin inc(a[i,j]);i:=i+1 end;
 i:=i1-1; j:=j1; while (a[i,j]<2) do  begin inc(a[i,j]);i:=i-1 end;
 i:=i1; j:=j1+1; while (a[i,j]<2) do  begin inc(a[i,j]);j:=j+1 end;
 i:=i1; j:=j1-1; while (a[i,j]<2) do  begin inc(a[i,j]);j:=j-1 end;

 i:=i2+1; j:=j2; while (a[i,j]<2) do  begin inc(a[i,j]);i:=i+1 end;
 i:=i2-1; j:=j2; while (a[i,j]<2) do  begin inc(a[i,j]);i:=i-1 end;
 i:=i2; j:=j2+1; while (a[i,j]<2) do  begin inc(a[i,j]);j:=j+1 end;
 i:=i2; j:=j2-1; while (a[i,j]<2) do  begin inc(a[i,j]);j:=j-1 end;

f:=true;

 for i:=ip-1  to ip+1 do
  for j:=jp-1  to jp+1 do
   if a[i,j]=0 then f:=False;
 If f then writeln('CHECKMATE') ELSE writeln('OTHER');
 readln;
end.

{$R+,S+,Q+,I+,O-}
{R-,S-,Q-,I-,O+}
const dx: array [1..8] of longint = (0,1,0,-1,1,1,-1,-1);
      dy: array [1..8] of longint = (1,0,-1,0,1,-1,1,-1);
var
  a: array [0..9,0..9] of longint;
  b: array [0..9,0..9] of boolean;
  xk,yk,x1,y1,x2,y2,x3,y3,x4,y4,d: longint;

procedure get(var x,y:longint);
var
  ch: char;
begin
  read(ch);
  while not (ch in ['a'..'h']) do read(ch);
  x:=Ord(ch)-96;
  read(y);
end;

procedure go(x,y,sx,sy:longint);
begin
  inc(x,sx); inc(y,sy);
  while (x > 0) and (y > 0) and (x < 9) and (y < 9) do
  begin
    b[x,y]:=True;
    if a[x,y] <> 0 then break;
    inc(x,sx); inc(y,sy);
  end;
end;

procedure go2(x,y,sx,sy:longint);
begin
  inc(x,sx); inc(y,sy);
  if (x > 0) and (y > 0) and (x < 9) and (y < 9) then
    b[x,y]:=True;
end;

begin
//  assign(input,'in'); reset(input);
//  assign(output,'out'); rewrite(output);
  get(x1,y1);
  get(x2,y2);
  get(x3,y3);
  get(x4,y4);
  fillchar(a,sizeof(a),0);
  a[x1,y1]:=1;
  a[x2,y2]:=2;
  a[x3,y3]:=3;
  fillchar(b,sizeof(b),False);
  for d:=1 to 4 do go(x1,y1,dx[d],dy[d]);
  for d:=1 to 4 do go(x2,y2,dx[d],dy[d]);
  for d:=1 to 8 do go2(x3,y3,dx[d],dy[d]);
  if not b[x4,y4] then writeln('OTHER') else
  begin
    for d:=1 to 8 do
    begin
      xk:=x4+dx[d];
      yk:=y4+dy[d];
      if (xk > 0) and (yk > 0) and (xk < 9) and (yk < 9) and (not b[xk,yk]) then
      begin
        writeln('OTHER');
        halt;
      end;
    end;
    writeln('CHECKMATE');
  end;
  close(input);
  close(output);
end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 s:string;
 i,j,x1,x2,x3,x4,y1,y2,y3,y4:longint;
 flag:boolean;
 pole:array[-10..100,-10..100] of integer;
begin
  read(s);
  x1:=ord(s[1])-96;
  x2:=ord(s[4])-96;
  x3:=ord(s[7])-96;
  x4:=ord(s[10])-96;
  y1:=ord(s[2])-48;
  y2:=ord(s[5])-48;
  y3:=ord(s[8])-48;
  y4:=ord(s[11])-48;
  flag:=true;
  for i:=x1+1 to 8 do
  if (x3=i) and (y3=y1) then flag:=false else if flag=true then pole[i,y1]:=1;
  flag:=true;
  for i:=x2+1 to 8 do
  if (x3=i) and (y3=y2) then flag:=false else if flag=true then pole[i,y2]:=1;
  flag:=true;
  for i:=x1-1 downto 1 do
  if (x3=i)  and (y3=y1)then flag:=false else if flag=true then pole[i,y1]:=1;
  flag:=true;
  for i:=x2-1 downto 1 do
  if (x3=i) and (y3=y2) then flag:=false else if flag=true then pole[i,y2]:=1;
  flag:=true;
  for i:=y1+1 to 8 do
  if (y3=i) and (x3=x1) then flag:=false else if flag=true then pole[x1,i]:=1;
  flag:=true;
  for i:=y2+1 to 8 do
  if (y3=i) and (x3=y2) then flag:=false else if flag=true then pole[x2,i]:=1;
  flag:=true;
  for i:=y1-1 downto 1 do
  if (y3=i) and (x3=y3) then flag:=false else if flag=true then pole[x1,i]:=1;
  flag:=true;
  for i:=y2-1 downto 1 do
  if (y3=i) and (x3=y2) then flag:=false else if flag=true then pole[x2,i]:=1;
  flag:=true;
  pole[x3+1,y3]:=1;
  pole[x3-1,y3]:=1;
  pole[x3+1,y3+1]:=1;
  pole[x3+1,y3-1]:=1;
  pole[x3-1,y3+1]:=1;
  pole[x3-1,y3-1]:=1;
  pole[x3,y3]:=1;
  pole[x3,y3+1]:=1;
  pole[x3,y3-1]:=1;
  if (pole[x4,y4]=1) and ((pole[x4+1,y4]=1) or (x4+1=9)) and ((pole[x4-1,y4]=1) or (x4-1=0)) and ((pole[x4,y4+1]=1) or (y4=8)) and ((pole[x4,y4-1]=1) or (y4=1)) and ((pole[x4+1,y4+1]=1) or (x4+1=9) or (y4+1=9)) and ((pole[x4+1,y4-1]=1) or (x4+1=9) or (y4-1=0)) and ((pole[x4-1,y4+1]=1) or (x4-1=0) or (y4+1=9)) and ((pole[x4-1,y4-1]=1) or (x4-1=0) or (y4-1=0)) then Writeln('CHECKMATE') else Writeln('OTHER');

end.

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 s:string;
 i,j,x1,x2,x3,x4,y1,y2,y3,y4:longint;
 flag:boolean;
 pole:array[-10..100,-10..100] of integer;
begin
  read(s);
  x1:=ord(s[1])-96;
  x2:=ord(s[4])-96;
  x3:=ord(s[7])-96;
  x4:=ord(s[10])-96;
  y1:=ord(s[2])-48;
  y2:=ord(s[5])-48;
  y3:=ord(s[8])-48;
  y4:=ord(s[11])-48;
  flag:=true;
  for i:=x1+1 to 8 do
  if (x3=i) and (y3=y1) then flag:=false else if flag=true then pole[i,y1]:=1;
  flag:=true;
  for i:=x2+1 to 8 do
  if (x3=i) and (y3=y2) then flag:=false else if flag=true then pole[i,y2]:=1;
  flag:=true;
  for i:=x1-1 downto 1 do
  if (x3=i)  and (y3=y1)then flag:=false else if flag=true then pole[i,y1]:=1;
  flag:=true;
  for i:=x2-1 downto 1 do
  if (x3=i) and (y3=y2) then flag:=false else if flag=true then pole[i,y2]:=1;
  flag:=true;
  for i:=y1+1 to 8 do
  if (y3=i) and (x3=x1) then flag:=false else if flag=true then pole[x1,i]:=1;
  flag:=true;
  for i:=y2+1 to 8 do
  if (y3=i) and (x3=y2) then flag:=false else if flag=true then pole[x2,i]:=1;
  flag:=true;
  for i:=y1-1 downto 1 do
  if (y3=i) and (x3=y3) then flag:=false else if flag=true then pole[x1,i]:=1;
  flag:=true;
  for i:=y2-1 downto 1 do
  if (y3=i) and (x3=y2) then flag:=false else if flag=true then pole[x2,i]:=1;
  flag:=true;
  pole[x3+1,y3]:=1;
  pole[x3-1,y3]:=1;
  pole[x3+1,y3+1]:=1;
  pole[x3+1,y3-1]:=1;
  pole[x3-1,y3+1]:=1;
  pole[x3-1,y3-1]:=1;
  pole[x3,y3]:=1;
  pole[x3,y3+1]:=1;
  pole[x3,y3-1]:=1;
  if (pole[x4,y4]=1) and ((pole[x4+1,y4]=1) or (x4+1=9)) and ((pole[x4-1,y4]=1) or (x4-1=0)) and ((pole[x4,y4+1]=1) or (y4=8)) and ((pole[x4,y4-1]=1) or (y4=1)) and ((pole[x4+1,y4+1]=1) or (x4+1=9) or (y4+1=9)) and ((pole[x4+1,y4-1]=1) or (x4+1=9) or (y4-1=0)) and ((pole[x4-1,y4+1]=1) or (x4-1=0) or (y4+1=9)) and ((pole[x4-1,y4-1]=1) or (x4-1=0) or (y4-1=0)) then Writeln('CHECKMATE') else Writeln('OTHER');
  {for i:=1 to 8 do begin
    for j:=1 to 8 do
  Write(pole[i,j],' ');
  Writeln;
  end;}

end.

{$O-,Q+,R+}
uses SysUtils;
const size=8;
type int=longint;
      tpoint=record x,y:int; end;
var t:array[1..4] of tpoint;
      a,v:array[1..size,1..size] of int;
procedure init;
begin
  {assign(input,'b.in');
  reset(input);
  assign(output,'b.out');
  rewrite(output);}
end;

procedure closing;
begin
  {close(input);
  close(output);}
end;

procedure readf(var a:tpoint);
var c:char;
begin
  read(c);
  while c=' ' do
    read(c);
  a.x:=ord(c)-ord('a')+1;
  read(c);
  a.y:=strtoint(c);
end;

function eq(var a,b:tpoint):boolean;
begin
  eq:=(a.x=b.x)and(a.y=b.y);
end;

function good(var p:tpoint):boolean;
begin
  good:=(p.x>=1)and(p.x<=size)and(p.y>=1)and(p.y<=size)and((v[p.x,p.y]=0)or(eq(p,t[4])));
end;

function good_s(var p:tpoint):boolean;
begin
  good_s:=(p.x>=1)and(p.x<=size)and(p.y>=1)and(p.y<=size);
end;

procedure other;
begin
  write('OTHER');
  closing;
  halt;
end;

procedure solve;
var i,di,dj,k:int;
      p,kn:tpoint;
begin
  fillchar(v,sizeof(v),0); fillchar(a,sizeof(a),0);
  for i:=1 to 4 do begin
    readf(t[i]);
    v[t[i].x,t[i].y]:=1;
  end;

  for k:=1 to 2 do begin
    for di:=-1 to 1 do
      for dj:=-1 to 1 do
        if (abs(di)<>abs(dj)) then begin
          p.x:=t[k].x+di; p.y:=t[k].y+dj;
          while good(p) do begin
            a[p.x,p.y]:=1;
            inc(p.x,di); inc(p.y,dj);
          end;
          if good_s(p) then
            a[p.x,p.y]:=1;
        end;
  end;
  for di:=-1 to 1 do
    for dj:=-1 to 1 do begin
      p.x:=t[3].x+di; p.y:=t[3].y+dj;
      if good_s(p)and((di<>0)or(dj<>0)) then
        a[t[3].x+di,t[3].y+dj]:=1;
    end;

  kn:=t[4];
  if a[kn.x,kn.y]=0 then
    other;
  for di:=-1 to 1 do
    for dj:=-1 to 1 do begin
      p.x:=kn.x+di; p.y:=kn.y+dj;
      if good_s(p)and(a[p.x,p.y]=0) then
        other;
    end;
  write('CHECKMATE');
end;

begin
  init;
  solve;
  closing;
end.

program Project1;
{$APPTYPE CONSOLE}
{$R+}
uses
SysUtils;
var
k,e,w,i,j,x1,x2,x3,x4,y1,y2,y3,y4,y,x:longint;
z:boolean;
s:string;
procedure svoboda;
begin
  write('OTHER');
  halt(0);
end;
begin
//reset(input,'input.txt');rewrite(output,'output.txt');
read(s);
x1:=ord(s[1])-96;
y1:=strtoint(s[2]);
x2:=ord(s[4])-96;
y2:=strtoint(s[5]);
x3:=ord(s[7])-96;
y3:=strtoint(s[8]);
x:=ord(s[10])-96;
y:=strtoint(s[11]);

if(x1<>x)or((x3=x1)and(((y3>y1)and(y3<y))or(y3<y1)and(y3>y)))then
if(x2<>x)or((x3=x2)and(((y3>y2)and(y3<y))or(y3<y2)and(y3>y)))then
if(y1<>y)or((y3=y1)and(((x3>x1)and(x3<x))or(x3<x1)and(x3>x)))then
if(y2<>y)or((y3=y2)and(((x3>x2)and(x3<x))or(x3<x2)and(x3>x)))then
svoboda;
for i:=y-1 to y+1 do
for j:=x-1 to x+1 do
if i>0 then
if i<9 then
if j>0 then
if j<9 then
begin
z:=true;
for w:=i-1 to i+1 do
for e:=j-1 to j+1 do
if w=y3 then
if e=x3 then z:=false;
k:=0;
if(i=y1)then
if i+j<>x1+y1 then
begin
  k:=1;
end;
if(j=x1)then
if i+j<>x1+y1 then
begin
  k:=2;
end;
if(i=y2)then
if i+j<>x2+y2 then
begin
  k:=3;
end;
if(j=x2)then
if i+j<>x2+y2 then
begin
  k:=4;
end;
if k=1 then
if((y3=y1)and(((x3>x1)and(x3<j))or(x3<x1)and(x3>j)))then k:=0;
if k=2 then
if((x3=x1)and(((y3>y1)and(y3<y))or(y3<y1)and(y3>y)))then k:=0;
if k=3 then
if((y3=y2)and(((x3>x2)and(x3<x))or(x3<x2)and(x3>x)))then k:=0;
if k=4 then
if ((x3=x2)and(((y3>y2)and(y3<y))or(y3<y2)and(y3>y)))then k:=0;
if z and (k=0) then svoboda;
end;

write('CHECKMATE');
end.

program pjb;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  iCnt,iRook1Y,iRook2Y,iKing1Y,iKing2Y: integer;
  cCnt,cRook1X,cRook2X,cKing1X,cKing2X: char;
  sTemp: string;
  bCheckmate: boolean;
  baArea: array ['a'..'z',0..9] of boolean;

function Ic(c1: char; i1: integer): char;
var
  cREsult: char;
begin
  case i1 of
    1:
    begin
      case c1 of
        'a': cResult := 'b';
        'b': cResult := 'c';
        'c': cResult := 'd';
        'd': cResult := 'e';
        'e': cResult := 'f';
        'f': cResult := 'g';
        'g': cResult := 'h';
        'h': cResult := 'h';
        end;
      end;
    -1:
    begin
      case c1 of
        'a': cResult := 'a';
        'b': cResult := 'a';
        'c': cResult := 'b';
        'd': cResult := 'c';
        'e': cResult := 'd';
        'f': cResult := 'e';
        'g': cResult := 'f';
        'h': cResult := 'g';
        end;
      end;
    end;
  Ic := cResult;
end;

begin
  Readln(sTemp);
  cRook1X := sTemp[1];
  iRook1Y := Strtoint(sTemp[2]);
  cRook2X := sTemp[4];
  iRook2Y := Strtoint(sTemp[5]);
  cKing1X := sTemp[7];
  iKing1Y := Strtoint(sTEmp[8]);
  cKIng2X := sTEmp[10];
  iKing2Y := Strtoint(sTEmp[11]);
  for cCnt := 'a' to 'z' do baArea[cCnt,0] := true;
  for cCnt := 'a' to 'z' do baArea[cCnt,9] := true;

  for iCnt := 1 to 8 do if (iCnt <> iRook1Y) then baArea[cRook1X,iCnt] := true;
  for iCnt := 1 to 8 do if (iCnt <> iRook2Y) then baArea[cRook2X,iCnt] := true;
  for cCnt := 'a' to 'z' do if (cCnt <> cRook1X) then baArea[cCnt,iRook1Y] := true;
  for cCnt := 'a' to 'z' do if (cCnt <> cRook2X) then baArea[cCnt,iRook2Y] := true;
  baArea[Ic(cKing1X,-1),iKing1Y] := true;
  baArea[Ic(cKing1X,1),iKing1Y] := true;
  baArea[cKing1X,iKing1Y - 1] := true;
  baArea[cKing1X,iKing1Y + 1] := true;
  baArea[Ic(cKing1X,-1),iKing1Y - 1] := true;
  baArea[Ic(cKing1X,-1),iKing1Y + 1] := true;
  baArea[Ic(cKing1X,1),iKing1Y - 1] := true;
  baArea[Ic(cKing1X,1),iKing1Y + 1] := true;
  if (iKing1Y = iRook1Y)
    then begin
      if (cKing1X < cRook1X)
        then begin
          for cCnt := 'a' to cKing1X do baArea[cCnt,iKing1Y] := false;
          end
        else begin
          for cCnt := cKing1X to 'h' do baArea[cCnt,iKing1Y] := false;
          end;
      end;
  if (iKing1Y = iRook2Y)
    then begin
      if (cKing1X < cRook2X)
        then begin
          for cCnt := 'a' to cKing1X do baArea[cCnt,iKing1Y] := false;
          end
        else begin
          for cCnt := cKing1X to 'h' do baArea[cCnt,iKing1Y] := false;
          end;
      end;
  if (cKing1X = cRook1X)
    then begin
      if (iKing1Y < iRook1Y)
        then begin
          for iCnt := 1 to iKing1Y do baArea[cKing1X,iCnt] := false;
          end
        else begin
          for iCnt := iKing1Y to 8 do baArea[cKing1X,iCnt] := false;
          end;
      end;

  bCheckmate := true;
  if (baArea[Ic(cKing2X,-1),iKing2Y] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,1),iKing2Y] = false)
    then bCheckmate := false;
  if (baArea[cKing2X,iKing2Y - 1] = false)
    then bCheckmate := false;
  if (baArea[cKing2X,iKing2Y + 1] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,-1),iKing2Y - 1] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,-1),iKing2Y + 1] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,1),iKing2Y - 1] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,1),iKing2Y + 1] = false)
    then bCheckmate := false;
  if (baArea[cKing2X,iKing2Y] = false)
    then bCheckmate := false;

  if (bCheckmate = true)
    then Writeln('CHECKMATE')
    else Writeln('OTHER');
end.

const dx:array[1..8] of longint=(-1,-1,0,1,1,1,0,-1);
      dy:array[1..8] of longint=(0,1,1,1,0,-1,-1,-1);
var a,b,aa,bb,c,cc,d,dd,i,j:longint;
    ch:char;
    e:array[0..9,0..9] of longint;

function check:boolean;
var i,x,y:longint;
begin
     check:=false;
     if e[d,dd]=0 then exit;
     for i:=1 to 8 do
     begin
          x:=d+dx[i]; y:=dd+dy[i];
          if (x>0) and (y>0) and (x<9) and (y<9) then
          begin
               if e[x,y]=0 then exit;
               if ((x=a) and (y=aa) and (e[x,y]=1)) or ((x=b) and (y=bb) and (e[x,y]=1)) then exit;
          end;
     end;
     check:=true;
end;

begin
     read(ch); a:=ord(ch)-96; read(aa);
     read(ch,ch); b:=ord(ch)-96; read(bb);
     read(ch,ch); c:=ord(ch)-96; read(cc);
     read(ch,ch); d:=ord(ch)-96; read(dd);
     for i:=1 to 8 do
     begin
          inc(e[i,aa]); inc(e[a,i]);
          inc(e[i,bb]); inc(e[b,i]);
     end;
     for i:=1 to 8 do inc(e[c+dx[i],cc+dy[i]],1);
     dec(e[a,aa]); dec(e[b,bb]); inc(e[c,cc]);
     if check then writeln('CHECKMATE')
     else writeln('OTHER');
end.

var board:array[1..8,1..8]of boolean;
    a:string[11];
    r,l,i,j,kr,kl:byte;
    ischeckmate:boolean;
begin
    for i:=1 to 8 do for j:=1 to 8 do board[i,j]:=false;
    readln(a);
    {white king}
    r:=ord(a[8])-48;
    kr:=r;
    l:=ord(a[7])-96;
    kl:=l;
    for i:=r-1 to r+1 do
        for j:=l-1 to l+1 do
            if (i<9)and(i>0)and(j<9)and(j>0) then
                board[i,j]:=true;
    {1st rook}
    r:=ord(a[2])-48;
    l:=ord(a[1])-96;
    for i:=1 to 8 do begin
        if i<>l then
            if (kr=r) then begin
                if ((kl<l)and(kl<i))or((kl>l)and(kl>i)) then
                    board[r,i]:=true
            end
            else
                board[r,i]:=true;
        if i<>r then
            if (kl=l) then begin
                if ((kr<r)and(kr<i))or((kr>r)and(kr>i)) then
                    board[i,l]:=true
            end
            else
                board[i,l]:=true;
    end;
    {2nd rook}
    r:=ord(a[5])-48;
    l:=ord(a[4])-96;
    for i:=1 to 8 do begin
        if i<>l then
            if (kr=r) then begin
                if ((kl<l)and(kl<i))or((kl>l)and(kl>i)) then
                    board[r,i]:=true
            end
            else
                board[r,i]:=true;
        if i<>r then
            if (kl=l) then begin
                if ((kr<r)and(kr<i))or((kr>r)and(kr>i)) then
                    board[i,l]:=true
            end
            else
                board[i,l]:=true;
    end;
    for i:=8 downto 1 do
        for j:=1 to 8 do begin
            if board[i,j] then
                write('T ')
            else
                write('F ');
            if j=8 then writeln;
        end;

    ischeckmate:=true;
    {black king}
    r:=ord(a[11])-48;
    l:=ord(a[10])-96;
    for i:=r-1 to r+1 do begin
        for j:=l-1 to l+1 do
            if (i<9)and(i>0)and(j<9)and(j>0)and(board[i,j]=false) then begin
                ischeckmate:=false;
                break;
            end;
        if ischeckmate=false then break;
    end;
    if ischeckmate then
        writeln('CHECKMATE')
    else
        writeln('OTHER');
readln;
end.

var board:array[1..8,1..8]of boolean;
    a:string[11];
    r,l,i,j:byte;
    ischeckmate:boolean;
begin
    readln(a);
    r:=ord(a[2])-48;
    l:=ord(a[1])-96;
    for i:=1 to 8 do begin
        if i<>r then board[i,l]:=true;
        if i<>l then board[r,i]:=true;
    end;
    r:=ord(a[5])-48;
    l:=ord(a[4])-96;
    for i:=1 to 8 do begin
        if i<>r then board[i,l]:=true;
        if i<>l then board[r,i]:=true;
    end;
    r:=ord(a[8])-48;
    l:=ord(a[7])-96;
    for i:=r-1 to r+1 do
        for j:=l-1 to l+1 do
            if (i<9)and(i>0)and(j<9)and(j>0) then
                board[i,j]:=true;
    ischeckmate:=true;
    r:=ord(a[11])-48;
    l:=ord(a[10])-96;
    for i:=r-1 to r+1 do begin
        for j:=l-1 to l+1 do
            if (i<9)and(i>0)and(j<9)and(j>0)and(board[i,j]=false) then begin
                ischeckmate:=false;
                break;
            end;
        if ischeckmate=false then break;
    end;
    if ischeckmate then
        writeln('CHECKMATE')
    else
        writeln('OTHER');
readln;
end.

var
n,m,i,j,x1,y1,x2,y2,x3,y3,x4,y4:longint;
xx,yy,nn:char;
a:array[0..10,0..10]of longint;

procedure ha;
    begin
     writeln('OTHER');
     halt(0);
    end;

function f(q,w:longint):boolean;
var i,j:longint;
 begin
  if (q<1)or(q>8)or(w<1)or(w>8) then
    begin
     f:=false;
     exit;
    end;

  if ((abs(q-x3)=1)or(abs(w-y3)=1))and((abs(q-x3))+(abs(w-y3))<=2) then
    begin
     f:=false;
     exit;
    end;

  if y1=w then
  for i:=x1+1 to n do
    begin
     if a[i,y1]<>0 then break;

     if (i=q) then
       begin
        f:=false;
        exit;
       end;
    end;

  if y1=w then
  for i:=x1-1 downto 1 do
    begin
     if a[i,y1]<>0 then break;

     if (i=q) then
       begin
        f:=false;
        exit;
       end;
    end;

  if x1=q then
  for j:=y1+1 to m do
    begin
     if a[x1,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
        exit;
       end;
    end;

  if x1=q then
  for j:=y1-1 downto 1 do
    begin
     if a[x1,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
        exit;
       end;
    end;

  if y2=w then
  for i:=x2+1 to n do
    begin
     if a[i,y2]<>0 then break;

     if (i=q) then
       begin
        f:=false;
        exit;
       end;
    end;

  if y2=w then
  for i:=x2-1 downto 1 do
    begin
     if a[i,y2]<>0 then break;

     if (i=q) then
       begin
        f:=false;
        exit;
       end;
    end;

  if x2=q then
  for j:=y2+1 to m do
    begin
     if a[x2,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
        exit;
       end;
    end;

  if x2=q then
  for j:=y2-1 downto 1 do
    begin
     if a[x2,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
        exit;
       end;
    end;

  f:=true;
 end;

 begin
  n:=8;
  m:=8;
  fillchar(a,sizeof(a),0);
  read(xx,yy);
  x1:=ord(xx)-96;
  y1:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x2:=ord(xx)-96;
  y2:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x3:=ord(xx)-96;
  y3:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x4:=ord(xx)-96;
  y4:=ord(yy)-48;

  a[x1,y1]:=1;

  a[x2,y2]:=2;

  a[x3,y3]:=3;

  if f(x4,y4) then ha;

  for i:=-1 to 1 do
    for j:=-1 to 1 do
      if (i<>0)or(j<>0) then if f(x4+i,y4+j) then ha;

  writeln('CHECKMATE');
 end.

var
n,m,i,j,x1,y1,x2,y2,x3,y3,x4,y4:longint;
xx,yy,nn:char;
a:array[0..10,0..10]of longint;

procedure ha;
    begin
     writeln('OTHER');
     halt(0);
    end;

function f(q,w:longint):boolean;
var i,j:longint;
 begin
  if (q<1)or(q>8)or(w<1)or(w>8) then
    begin
     f:=false;
     exit;
    end;

  if abs(q-x3)+abs(w-y3)=1 then
    begin
     f:=false;
     exit;
    end;

  if y1=w then
  for i:=x1+1 to n do
    begin
     if a[i,y1]<>0 then break;

     if (i=q) then
       begin
        f:=false;
        exit;
       end;
    end;

  if y1=w then
  for i:=x1-1 downto 1 do
    begin
     if a[i,y1]<>0 then break;

     if (i=q) then
       begin
        f:=false;
        exit;
       end;
    end;

  if x1=q then
  for j:=y1+1 to m do
    begin
     if a[x1,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
        exit;
       end;
    end;

  if x1=q then
  for j:=y1-1 downto 1 do
    begin
     if a[x1,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
        exit;
       end;
    end;

  if y2=w then
  for i:=x2+1 to n do
    begin
     if a[i,y2]<>0 then break;

     if (i=q) then
       begin
        f:=false;
        exit;
       end;
    end;

  if y2=w then
  for i:=x2-1 downto 1 do
    begin
     if a[i,y2]<>0 then break;

     if (i=q) then
       begin
        f:=false;
        exit;
       end;
    end;

  if x2=q then
  for j:=y2+1 to m do
    begin
     if a[x2,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
        exit;
       end;
    end;

  if x2=q then
  for j:=y2-1 downto 1 do
    begin
     if a[x2,j]<>0 then break;

     if (j=w) then
       begin
        f:=false;
        exit;
       end;
    end;

  f:=true;
 end;

 begin
  n:=8;
  m:=8;
  fillchar(a,sizeof(a),0);
  read(xx,yy);
  x1:=ord(xx)-96;
  y1:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x2:=ord(xx)-96;
  y2:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x3:=ord(xx)-96;
  y3:=ord(yy)-48;

  read(nn);

  read(xx,yy);
  x4:=ord(xx)-96;
  y4:=ord(yy)-48;

  a[x1,y1]:=1;

  a[x2,y2]:=2;

  a[x3,y3]:=3;

  if f(x4,y4) then ha;

  for i:=-1 to 1 do
    for j:=-1 to 1 do
      if (i<>0)or(j<>0) then if f(x4+i,y4+j) then ha;

  writeln('CHECKMATE');
 end.

uses math;
var flag:boolean;
    a:array[-10..100,-10..100]of longint;
    x1,x2,x3,x4,y1,y2,y3,y4,i,j:longint;
    ch:char;
    procedure rec(x,y,xx,yy:longint);
     var w:longint;
     begin
       while (x+xx>0)and(x+xx<9) and (y+yy>0)and(y+yy<9) do
        begin
          x:=x+xx;
          y:=y+yy;
          w:=a[x,y];
          a[x,y]:=0;
          if w=2 then break;
        end;
     end;
  begin
    read(ch,y1);
    x1:=ord(ch)-96;
    read(ch,ch,y2);
    x2:=ord(ch)-96;
    read(ch,ch,y3);
    x3:=ord(ch)-96;
    read(ch,ch,y4);
    x4:=ord(ch)-96;

    for i:=0 to 9 do
     for j:=0 to 9 do
      a[i,j]:=0;
     for i:=1 to 8 do
     for j:=1 to 8 do
      a[i,j]:=1;
    a[x1,y1]:=2;
    a[x2,y2]:=2;
    a[x3,y3]:=2;
    a[x4,y4]:=3;
    rec(x1,y1,1,0);
    rec(x1,y1,-1,0);
    rec(x1,y1,0,1);
    rec(x1,y1,0,-1);
    rec(x2,y2,1,0);
    rec(x2,y2,-1,0);
    rec(x2,y2,0,1);
    rec(x2,y2,0,-1);

    flag:=true;
    for i:=1 to 8 do
     for j:=1 to 8 do
      if ( max(abs(x4-i),abs(y4-j))<=1 ) and (a[i,j]>0) then flag:=false;
    if flag then writeln('CHECKMATE')
            else writeln('OTHER');
  End.

program sdfdsv;

var i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;
	ch:char;
	f,g,h:array[0..9,0..9] of byte;
	r:integer;

BEGIN

read(ch);
if ch='a' then i1:=1;
if ch='b' then i1:=2;
if ch='c' then i1:=3;
if ch='d' then i1:=4;
if ch='e' then i1:=5;
if ch='f' then i1:=6;
if ch='g' then i1:=7;
if ch='h' then i1:=8;
read(ch);
Val(ch,j1,r);
read(ch);
read(ch);
if ch='a' then i2:=1;
if ch='b' then i2:=2;
if ch='c' then i2:=3;
if ch='d' then i2:=4;
if ch='e' then i2:=5;
if ch='f' then i2:=6;
if ch='g' then i2:=7;
if ch='h' then i2:=8;
read(ch);
Val(ch,j2,r);
read(ch);
read(ch);
if ch='a' then i3:=1;
if ch='b' then i3:=2;
if ch='c' then i3:=3;
if ch='d' then i3:=4;
if ch='e' then i3:=5;
if ch='f' then i3:=6;
if ch='g' then i3:=7;
if ch='h' then i3:=8;
read(ch);
Val(ch,j3,r);
read(ch);
read(ch);
if ch='a' then i4:=1;
if ch='b' then i4:=2;
if ch='c' then i4:=3;
if ch='d' then i4:=4;
if ch='e' then i4:=5;
if ch='f' then i4:=6;
if ch='g' then i4:=7;
if ch='h' then i4:=8;
read(ch);
Val(ch,j4,r);
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;
end;
end;
for i:=0 to 9 do f[i,0]:=1;
for i:=0 to 9 do f[i,9]:=1;
for j:=1 to 8 do f[0,j]:=1;
for j:=1 to 8 do f[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;
end;
end;
for i:=0 to 9 do g[i,0]:=1;
for i:=0 to 9 do g[i,9]:=1;
for j:=1 to 8 do g[0,j]:=1;
for j:=1 to 8 do g[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;
end;
end;
for i:=0 to 9 do h[i,0]:=1;
for i:=0 to 9 do h[i,9]:=1;
for j:=1 to 8 do h[0,j]:=1;
for j:=1 to 8 do h[9,j]:=1;
if (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4-1,j4+1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4+1,j4]=1)and(f[i4+1,j4+1]=1) then
begin
if ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')
else writeln('CHECKMATE');
end
else writeln('OTHER');
END.

program sdfdsv;

var i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;
	ch:char;
	f,g,h:array[0..9,0..9] of byte;
	r:integer;

BEGIN

read(ch);
if ch='a' then i1:=1;
if ch='b' then i1:=2;
if ch='c' then i1:=3;
if ch='d' then i1:=4;
if ch='e' then i1:=5;
if ch='f' then i1:=6;
if ch='g' then i1:=7;
if ch='h' then i1:=8;
read(ch);
Val(ch,j1,r);
read(ch);
read(ch);
if ch='a' then i2:=1;
if ch='b' then i2:=2;
if ch='c' then i2:=3;
if ch='d' then i2:=4;
if ch='e' then i2:=5;
if ch='f' then i2:=6;
if ch='g' then i2:=7;
if ch='h' then i2:=8;
read(ch);
Val(ch,j2,r);
read(ch);
read(ch);
if ch='a' then i3:=1;
if ch='b' then i3:=2;
if ch='c' then i3:=3;
if ch='d' then i3:=4;
if ch='e' then i3:=5;
if ch='f' then i3:=6;
if ch='g' then i3:=7;
if ch='h' then i3:=8;
read(ch);
Val(ch,j3,r);
read(ch);
read(ch);
if ch='a' then i4:=1;
if ch='b' then i4:=2;
if ch='c' then i4:=3;
if ch='d' then i4:=4;
if ch='e' then i4:=5;
if ch='f' then i4:=6;
if ch='g' then i4:=7;
if ch='h' then i4:=8;
read(ch);
Val(ch,j4,r);
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;
end;
end;
for i:=0 to 9 do f[i,0]:=1;
for i:=0 to 9 do f[i,9]:=1;
for j:=1 to 8 do f[0,j]:=1;
for j:=1 to 8 do f[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;
end;
end;
for i:=0 to 9 do g[i,0]:=1;
for i:=0 to 9 do g[i,9]:=1;
for j:=1 to 8 do g[0,j]:=1;
for j:=1 to 8 do g[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;
end;
end;
for i:=0 to 9 do h[i,0]:=1;
for i:=0 to 9 do h[i,9]:=1;
for j:=1 to 8 do h[0,j]:=1;
for j:=1 to 8 do h[9,j]:=1;
if (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4+1]=1) then
begin
if ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')
else writeln('CHECKMATE');
end
else writeln('OTHER');
END.

program bv;

var i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;
	ch:char;
	f,g,h:array[0..9,0..9] of byte;
	r:integer;

BEGIN
read(ch);
if ch='a' then i1:=1;
if ch='b' then i1:=2;
if ch='c' then i1:=3;
if ch='d' then i1:=4;
if ch='e' then i1:=5;
if ch='f' then i1:=6;
if ch='g' then i1:=7;
if ch='h' then i1:=8;
read(ch);
Val(ch,j1,r);
read(ch);
read(ch);
if ch='a' then i2:=1;
if ch='b' then i2:=2;
if ch='c' then i2:=3;
if ch='d' then i2:=4;
if ch='e' then i2:=5;
if ch='f' then i2:=6;
if ch='g' then i2:=7;
if ch='h' then i2:=8;
read(ch);
Val(ch,j2,r);
read(ch);
read(ch);
if ch='a' then i3:=1;
if ch='b' then i3:=2;
if ch='c' then i3:=3;
if ch='d' then i3:=4;
if ch='e' then i3:=5;
if ch='f' then i3:=6;
if ch='g' then i3:=7;
if ch='h' then i3:=8;
read(ch);
Val(ch,j3,r);
read(ch);
read(ch);
if ch='a' then i4:=1;
if ch='b' then i4:=2;
if ch='c' then i4:=3;
if ch='d' then i4:=4;
if ch='e' then i4:=5;
if ch='f' then i4:=6;
if ch='g' then i4:=7;
if ch='h' then i4:=8;
read(ch);
Val(ch,j4,r);
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;
end;
end;
for i:=0 to 9 do f[i,0]:=1;
for i:=0 to 9 do f[i,9]:=1;
for j:=1 to 8 do f[0,j]:=1;
for j:=1 to 8 do f[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;
end;
end;
for i:=0 to 9 do g[i,0]:=1;
for i:=0 to 9 do g[i,9]:=1;
for j:=1 to 8 do g[0,j]:=1;
for j:=1 to 8 do g[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;
end;
end;
for i:=0 to 9 do h[i,0]:=1;
for i:=0 to 9 do h[i,9]:=1;
for j:=1 to 8 do h[0,j]:=1;
for j:=1 to 8 do h[9,j]:=1;
if (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4+1]=1) then
begin
if ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')
else writeln('CHECKMATE');
end
else writeln('OTHER');
END.

program sdfdsv;

var i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;
	ch:char;
	f,g,h:array[0..9,0..9] of byte;
	r:integer;

BEGIN

read(ch);
if ch='a' then i1:=1;
if ch='b' then i1:=2;
if ch='c' then i1:=3;
if ch='d' then i1:=4;
if ch='e' then i1:=5;
if ch='f' then i1:=6;
if ch='g' then i1:=7;
if ch='h' then i1:=8;
read(ch);
Val(ch,j1,r);
read(ch);
read(ch);
if ch='a' then i2:=1;
if ch='b' then i2:=2;
if ch='c' then i2:=3;
if ch='d' then i2:=4;
if ch='e' then i2:=5;
if ch='f' then i2:=6;
if ch='g' then i2:=7;
if ch='h' then i2:=8;
read(ch);
Val(ch,j2,r);
read(ch);
read(ch);
if ch='a' then i3:=1;
if ch='b' then i3:=2;
if ch='c' then i3:=3;
if ch='d' then i3:=4;
if ch='e' then i3:=5;
if ch='f' then i3:=6;
if ch='g' then i3:=7;
if ch='h' then i3:=8;
read(ch);
Val(ch,j3,r);
read(ch);
read(ch);
if ch='a' then i4:=1;
if ch='b' then i4:=2;
if ch='c' then i4:=3;
if ch='d' then i4:=4;
if ch='e' then i4:=5;
if ch='f' then i4:=6;
if ch='g' then i4:=7;
if ch='h' then i4:=8;
read(ch);
Val(ch,j4,r);
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;
end;
end;
for i:=0 to 9 do f[i,0]:=1;
for i:=0 to 9 do f[i,9]:=1;
for j:=1 to 8 do f[0,j]:=1;
for j:=1 to 8 do f[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;
end;
end;
for i:=0 to 9 do g[i,0]:=1;
for i:=0 to 9 do g[i,9]:=1;
for j:=1 to 8 do g[0,j]:=1;
for j:=1 to 8 do g[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;
end;
end;
for i:=0 to 9 do h[i,0]:=1;
for i:=0 to 9 do h[i,9]:=1;
for j:=1 to 8 do h[0,j]:=1;
for j:=1 to 8 do h[9,j]:=1;
if (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4+1,j4]=1)and(f[i4+1,j4+1]=1) then
begin
if ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')
else writeln('CHECKMATE');
end
else writeln('OTHER');
END.

program bv;

var i,i1,i2,i3,i4,j1,j2,j3,j4,j : byte;
	ch:char;
	f,g,h:array[0..10,0..10] of byte;
	r:integer;

BEGIN
read(ch);
if ch='a' then i1:=1;
if ch='b' then i1:=2;
if ch='c' then i1:=3;
if ch='d' then i1:=4;
if ch='e' then i1:=5;
if ch='f' then i1:=6;
if ch='g' then i1:=7;
if ch='h' then i1:=8;
read(ch);
Val(ch,j1,r);
read(ch);
read(ch);
if ch='a' then i2:=1;
if ch='b' then i2:=2;
if ch='c' then i2:=3;
if ch='d' then i2:=4;
if ch='e' then i2:=5;
if ch='f' then i2:=6;
if ch='g' then i2:=7;
if ch='h' then i2:=8;
read(ch);
Val(ch,j2,r);
read(ch);
read(ch);
if ch='a' then i3:=1;
if ch='b' then i3:=2;
if ch='c' then i3:=3;
if ch='d' then i3:=4;
if ch='e' then i3:=5;
if ch='f' then i3:=6;
if ch='g' then i3:=7;
if ch='h' then i3:=8;
read(ch);
Val(ch,j3,r);
read(ch);
read(ch);
if ch='a' then i4:=1;
if ch='b' then i4:=2;
if ch='c' then i4:=3;
if ch='d' then i4:=4;
if ch='e' then i4:=5;
if ch='f' then i4:=6;
if ch='g' then i4:=7;
if ch='h' then i4:=8;
read(ch);
Val(ch,j4,r);
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(i=i2)or(j=j1)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then f[i,j]:=1;
end;
end;
for i:=0 to 9 do f[i,0]:=1;
for i:=0 to 9 do f[i,9]:=1;
for j:=1 to 8 do f[0,j]:=1;
for j:=1 to 8 do f[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i2)or(j=j2)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then g[i,j]:=1;
end;
end;
for i:=0 to 9 do g[i,0]:=1;
for i:=0 to 9 do g[i,9]:=1;
for j:=1 to 8 do g[0,j]:=1;
for j:=1 to 8 do g[9,j]:=1;
for i:=1 to 8 do begin
for j:=1 to 8 do begin
if (i=i1)or(j=j1)or((abs(i-i3)<=1)and(abs(j-j3)<=1)) then h[i,j]:=1;
end;
end;
for i:=0 to 9 do h[i,0]:=1;
for i:=0 to 9 do h[i,9]:=1;
for j:=1 to 8 do h[0,j]:=1;
for j:=1 to 8 do h[9,j]:=1;
if (f[i4,j4]=1)and(f[i4,j4-1]=1)and(f[i4,j4+1]=1)and(f[i4-1,j4-1]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4-1]=1)and(f[i4-1,j4]=1)and(f[i4+1,j4+1]=1) then
begin
if ((abs(i4-i1)<=1)and(abs(j4-j1)<=1)and(g[i1,j1]=0))or((abs(i4-i2)<=1)and(abs(j4-j2)<=1)and(h[i2,j2]=0)) then writeln('OTHER')
else writeln('CHECKMATE');
end
else writeln('OTHER');
END.

const
  hx:array[1..9] of longint=(1,1,1,0,0,-1,-1,-1,0);
  hy:array[1..9] of longint=(0,1,-1,1,-1,0,-1,1,0);

var
  s:string;
  x1,y1,x2,y2,bx,by,wx,wy,i,cx,cy,res:longint;
  was:array[1..8,1..8] of boolean;

begin
  readln(s);
  x1:=ord(s[1])-96;
  y1:=ord(s[2])-48;
  x2:=ord(s[4])-96;
  y2:=ord(s[5])-48;
  wx:=ord(s[7])-96;
  wy:=ord(s[8])-48;
  bx:=ord(s[10])-96;
  by:=ord(s[11])-48;
  for i:=1 to 8 do begin
    cx:=wx+hx[i];
    cy:=wy+hy[i];
    if (cx<1)or (cy<1) or (cx>8) or (cy>8) then continue;
    was[cx][cy]:=true;
  end;
  res:=0;
  for i:=1 to 9 do begin
    cx:=bx+hx[i];
    cy:=by+hy[i];
    if (cx<1)or (cy<1) or (cx>8) or (cy>8)then inc(res) else
    if (was[cx][cy])then inc(res) else
    if ((cx=x1) or (cy=y1)) and ((cx<>x1) or (cy<>y1)) then inc(res) else
    if ((cx=x2) or (cy=y2)) and ((cx<>x2) or (cy<>y2)) then inc(res);
  end;
  if (res=9)
    then writeln('CHECKMATE')
    else writeln('OTHER');
end.

const
  hx:array[1..9] of longint=(1,1,1,0,0,-1,-1,-1,0);
  hy:array[1..9] of longint=(0,1,-1,1,-1,0,-1,1,0);

var
  s:string;
  x1,y1,x2,y2,bx,by,wx,wy,i,cx,cy,res:longint;
  was:array[1..8,1..8] of boolean;

begin
  readln(s);
  x1:=ord(s[1])-96;
  y1:=ord(s[2])-48;
  x2:=ord(s[4])-96;
  y2:=ord(s[5])-48;
  wx:=ord(s[7])-96;
  wy:=ord(s[8])-48;
  bx:=ord(s[10])-96;
  by:=ord(s[11])-48;
  for i:=1 to 8 do begin
    cx:=wx+hx[i];
    cy:=wy+hy[i];
    if (cx<1)or (cy<1) or (cx>8) or (cy>8) then continue;
    was[cx][cy]:=true;
  end;
  res:=0;
  for i:=1 to 9 do begin
    cx:=bx+hx[i];
    cy:=by+hy[i];
    if (cx=wx)and (cx=wy)then begin
      res:=-1;
      break;
    end;
    if (cx<1)or (cy<1) or (cx>8) or (cy>8)then inc(res) else
    if (was[cx][cy])then inc(res) else
    if (ord(cx=x1) + ord(cy=y1) = 1)then inc(res) else
    if (ord(cx=x2) + ord(cy=y2) = 1)then inc(res);
  end;
  if (res=9)
    then writeln('CHECKMATE')
    else writeln('OTHER');
end.

type Tpos=record x,y:byte; end;
var p:array[1..4]of Tpos;
    ax:array[1..4]of string[3];
    board:array[0..9,0..9]of shortint;
    mat:boolean;
    i,x,y,j:shortint;
begin
 for y:=0 to 9 do
  for x:=0 to 9 do
   if ((x=0)or(x=9)or(y=0)or(y=9)) then
    board[x,y]:=5 else board[x,y]:=0;

 for i:=1 to 4 do begin
  read(ax[i]);
  p[i].x:=1 + (ord(ax[i,1])-ord('a'));
  p[i].y:=1 + (ord(ax[i,2])-ord('1'));
  if (i<4) then board[p[i].x,p[i].y]:=-1;
 end;
 mat:=true;

 for i:=1 to 2 do begin
  y:=p[i].y;
  for x:=p[i].x downto 1 do
   if (x<>p[i].x) then
    if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);
  for x:=p[i].x to 8 do
   if (x<>p[i].x) then
    if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);
  x:=p[i].x;
  for y:=p[i].y downto 1 do
   if (y<>p[i].y) then
    if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);
  for y:=p[i].y to 8 do
   if (y<>p[i].y) then
    if (board[x,y]<0)then begin dec(board[x,y]); break; end else inc(board[x,y]);
 end;

 for i:=1 to 3 do board[p[i].x,p[i].y]:=-board[p[i].x,p[i].y]-1;

 for y:=-1 to 1 do
  for x:=-1 to 1 do
   if ((x<>0)or(y<>0))then inc(board[p[3].x+x,p[3].y+y]);

 for y:=-1 to 1 do
  if mat then
   for x:=-1 to 1 do
    if ((y<>0)or(x<>0))then
     if (board[p[4].x+x,p[4].y+y]=0) then begin mat:=false; break; end;

 if mat then write('CHECKMATE') else write('OTHER');
end.

type Tpos=record x,y:byte; end;
var p:array[1..4]of Tpos;
    ax:array[1..4]of string[2];
    board:array[0..9,0..9]of shortint;
    mat:boolean;
    i,j:shortint;
begin
 for i:=1 to 4 do begin
  read(ax[i]);
  p[i].x:=1 + (ord(ax[i,1])-ord('a'));
  p[i].y:=1 + (ord(ax[i,2])-ord('1'));
 end;
 mat:=true;

 for i:=0 to 9 do
  for j:=0 to 9 do
   if ((i=0)or(i=9)or(j=0)or(j=9)) then
    board[i,j]:=5 else board[i,j]:=0;

 for j:=1 to 2 do
  for i:=1 to 8 do begin
   inc(board[i,p[j].y]);
   inc(board[p[j].x,i]);
  end;

  for i:=-1 to 1 do
   for j:=-1 to 1 do
    if ((i<>0)or(j<>0))then inc(board[p[3].x+i,p[3].y+j]);

 for i:=1 to 2 do dec(board[p[i].x,p[i].y],2);

  for i:=-1 to 1 do begin
   if mat then
    for j:=-1 to 1 do
     if ((i<>0)or(j<>0))then
      if (board[p[4].x+i,p[4].y+j]=0) then begin mat:=false; break; end;
  end;

 if mat then write('CHECKMATE') else write('OTHER');
end.

type Tpos=record x,y:byte; end;
var p:array[1..4]of Tpos;
    ax:array[1..4]of string[3];
    board:array[0..9,0..9]of shortint;
    mat:boolean;
    i,x,y:shortint;
begin
 for i:=1 to 4 do begin
  read(ax[i]);
  p[i].x:=1 + (ord(ax[i,1])-ord('a'));
  p[i].y:=1 + (ord(ax[i,2])-ord('1'));
 end;
 mat:=true;

 for y:=0 to 9 do
  for x:=0 to 9 do
   if ((x=0)or(x=9)or(y=0)or(y=9)) then
    board[x,y]:=5 else board[x,y]:=0;

 for i:=1 to 2 do
  for x:=1 to 8 do begin
   inc(board[x,p[i].y]);
   inc(board[p[i].x,x]);
  end;

  for y:=-1 to 1 do
   for x:=-1 to 1 do
    if ((x<>0)or(y<>0))then inc(board[p[3].x+x,p[3].y+y]);

 for i:=1 to 2 do dec(board[p[i].x,p[i].y],2);

  for y:=-1 to 1 do
   if mat then
    for x:=-1 to 1 do
     if ((y<>0)or(x<>0))then
      if (board[p[4].x+x,p[4].y+y]=0) then begin mat:=false; break; end;

 if mat then write('CHECKMATE') else write('OTHER');
end.

var
    d:array [1..8,1..8] of byte;
    i,j,n,k,x,y:longint;
    s:string;
BEGIN
fillchar(d,sizeof(d),0);
readln(s);
n:=1;
while n<=10 do
    begin
    j:=ord(s[n])-96;
    val(s[n+1],i);
    if (n=1)or(n=4) then
        begin
        d[i,j]:=1;
        for k:=1 to 8 do if d[i,k]=0 then d[i,k]:=4;
        for k:=1 to 8 do if d[k,j]=0 then d[k,j]:=4;
        end
        else if n=7 then
            begin
            d[i,j]:=2;
            if i>1 then d[i-1,j]:=4;
            if i<8 then d[i+1,j]:=4;
            if j>1 then d[i,j-1]:=4;
            if j<8 then d[i,j+1]:=4;
            if (i>1)and(j>1) then d[i-1,j-1]:=4;
            if (i<8)and(j<8) then d[i+1,j+1]:=4;
            if (j>1)and(i<8) then d[i+1,j-1]:=4;
            if (j<8)and(i>1) then d[i-1,j+1]:=4;
            end
            else
                begin
                x:=i;
                y:=j;
                end;
    inc(n,3);
    end;
n:=0;k:=0;
if d[x,y]=4 then
    begin
    if x>1 then
        begin
        if d[x-1,y]=4 then inc(n);
        inc(k);
        end;
    if x<8 then
        begin
        if d[x+1,y]=4 then inc(n);
        inc(k);
        end;
    if y>1 then
        begin
        if d[x,y-1]=4 then inc(n);
        inc(k);
        end;
    if y<8 then
        begin
        if d[x,y+1]=4 then inc(n);
        inc(k);
        end;
    if (x>1)and(y>1) then
        begin
        if d[x-1,y-1]=4 then inc(n);
        inc(k);
        end;
    if (x<8)and(y<8) then
        begin
        if d[x+1,y+1]=4 then inc(n);
        inc(k);
        end;
    if (y>1)and(x<8) then
        begin
        if d[x+1,y-1]=4 then inc(n);
        inc(k);
        end;
    if (y<8)and(x>1) then
        begin
        if d[x-1,y+1]=4 then inc(n);
        inc(k);
        end;
    if n=k then writeln('CHECKMATE') else writeln('OTHER');
    end
else writeln('OTHER');

{for i:=1 to 8 do
    begin
    for j:=1 to 8 do write(d[i,j],' ');
    writeln;
    end;}
END.

var
    d:array [1..8,1..8] of byte;
    i,j,n,k,x,y,xx,yy,x1,x2,y1,y2:longint;
    s:string;
BEGIN
fillchar(d,sizeof(d),0);
readln(s);
n:=1;
while n<=10 do
    begin
    j:=ord(s[n])-96;
    val(s[n+1],i);
    if n=1 then
        begin
        x1:=i;
        y1:=j;
        end
        else if n=4 then
            begin
            x2:=i;
            y2:=j;
            end
            else if n=7 then
                begin
                xx:=i;
                yy:=j;
                d[xx,yy]:=2;
                end
                else
                    begin
                    x:=i;
                    y:=j;
                    end;
    inc(n,3);
    end;

if x1<>xx then for k:=1 to 8 do d[x1,k]:=4
    else if y1<yy then for k:=1 to yy-1 do d[x1,k]:=4
        else for k:=yy+1 to 8 do d[x1,k]:=4;
if y1<>yy then for k:=1 to 8 do d[k,y1]:=4
    else if x1<xx then for k:=1 to xx-1 do d[k,y1]:=4
        else for k:=xx+1 to 8 do d[k,y1]:=4;
if x2<>xx then for k:=1 to 8 do d[x2,k]:=4
    else if y2<yy then for k:=1 to yy-1 do d[x2,k]:=4
        else for k:=yy+1 to 8 do d[x2,k]:=4;
if y2<>yy then for k:=1 to 8 do d[k,y2]:=4
    else if x2<xx then for k:=1 to xx-1 do d[k,y2]:=4
        else for k:=xx+1 to 8 do d[k,y2]:=4;
d[x1,y1]:=1;
d[x2,y2]:=1;

if xx>1 then d[xx-1,yy]:=4;
if xx<8 then d[xx+1,yy]:=4;
if yy>1 then d[xx,yy-1]:=4;
if yy<8 then d[xx,yy+1]:=4;
if (xx>1)and(yy>1) then d[xx-1,yy-1]:=4;
if (xx<8)and(yy<8) then d[xx+1,yy+1]:=4;
if (yy>1)and(xx<8) then d[xx+1,yy-1]:=4;
if (yy<8)and(xx>1) then d[xx-1,yy+1]:=4;

n:=0;k:=0;
if d[x,y]=4 then
    begin
    if x>1 then
        begin
        if d[x-1,y]=4 then inc(n);
        inc(k);
        end;
    if x<8 then
        begin
        if d[x+1,y]=4 then inc(n);
        inc(k);
        end;
    if y>1 then
        begin
        if d[x,y-1]=4 then inc(n);
        inc(k);
        end;
    if y<8 then
        begin
        if d[x,y+1]=4 then inc(n);
        inc(k);
        end;
    if (x>1)and(y>1) then
        begin
        if d[x-1,y-1]=4 then inc(n);
        inc(k);
        end;
    if (x<8)and(y<8) then
        begin
        if d[x+1,y+1]=4 then inc(n);
        inc(k);
        end;
    if (y>1)and(x<8) then
        begin
        if d[x+1,y-1]=4 then inc(n);
        inc(k);
        end;
    if (y<8)and(x>1) then
        begin
        if d[x-1,y+1]=4 then inc(n);
        inc(k);
        end;
    if n=k then writeln('CHECKMATE') else writeln('OTHER');
    end
else writeln('OTHER');

{for i:=1 to 8 do
    begin
    for j:=1 to 8 do
        if d[i,j]=0 then write('- ') else write(d[i,j],' ');
    writeln;
    end;}
END.

var
    d:array [1..8,1..8] of byte;
    i,j,n,k,x,y,xx,yy,x1,x2,y1,y2:longint;
    s:string;
BEGIN
fillchar(d,sizeof(d),0);
readln(s);
n:=1;
while n<=10 do
    begin
    j:=ord(s[n])-96;
    val(s[n+1],i);
    if n=1 then
        begin
        x1:=i;
        y1:=j;
        end
        else if n=4 then
            begin
            x2:=i;
            y2:=j;
            end
            else if n=7 then
                begin
                d[i,j]:=2;
                xx:=i;
                yy:=j;
                if i>1 then d[i-1,j]:=4;
                if i<8 then d[i+1,j]:=4;
                if j>1 then d[i,j-1]:=4;
                if j<8 then d[i,j+1]:=4;
                if (i>1)and(j>1) then d[i-1,j-1]:=4;
                if (i<8)and(j<8) then d[i+1,j+1]:=4;
                if (j>1)and(i<8) then d[i+1,j-1]:=4;
                if (j<8)and(i>1) then d[i-1,j+1]:=4;
                end
                else
                    begin
                    x:=i;
                    y:=j;
                    end;
    inc(n,3);
    end;

if x1<>xx then for k:=1 to 8 do d[x1,k]:=4
    else if y1<yy then for k:=1 to yy-1 do d[x1,k]:=4
        else for k:=yy+1 to 8 do d[x1,k]:=4;
if y1<>yy then for k:=1 to 8 do d[k,y1]:=4
    else if x1<xx then for k:=1 to xx-1 do d[k,y1]:=4
        else for k:=xx+1 to 8 do d[k,y1]:=4;
if x2<>xx then for k:=1 to 8 do d[x2,k]:=4
    else if y2<yy then for k:=1 to yy-1 do d[x2,k]:=4
        else for k:=yy+1 to 8 do d[x2,k]:=4;
if y2<>yy then for k:=1 to 8 do d[k,y2]:=4
    else if x2<xx then for k:=1 to xx-1 do d[k,y2]:=4
        else for k:=xx+1 to 8 do d[k,y2]:=4;
d[x1,y1]:=1;
d[x2,y2]:=1;

n:=0;k:=0;
if d[x,y]=4 then
    begin
    if x>1 then
        begin
        if d[x-1,y]=4 then inc(n);
        inc(k);
        end;
    if x<8 then
        begin
        if d[x+1,y]=4 then inc(n);
        inc(k);
        end;
    if y>1 then
        begin
        if d[x,y-1]=4 then inc(n);
        inc(k);
        end;
    if y<8 then
        begin
        if d[x,y+1]=4 then inc(n);
        inc(k);
        end;
    if (x>1)and(y>1) then
        begin
        if d[x-1,y-1]=4 then inc(n);
        inc(k);
        end;
    if (x<8)and(y<8) then
        begin
        if d[x+1,y+1]=4 then inc(n);
        inc(k);
        end;
    if (y>1)and(x<8) then
        begin
        if d[x+1,y-1]=4 then inc(n);
        inc(k);
        end;
    if (y<8)and(x>1) then
        begin
        if d[x-1,y+1]=4 then inc(n);
        inc(k);
        end;
    if n=k then writeln('CHECKMATE') else writeln('OTHER');
    end
else writeln('OTHER');

{for i:=1 to 8 do
    begin
    for j:=1 to 8 do
        if d[i,j]=0 then write('- ') else write(d[i,j],' ');
    writeln;
    end;}
END.

program baib;

const   fi='';
        fo='';

var     f,g:text;
        a,c:array[0..10,0..10]of longint;
        s1,s2,t1,t2,w1,w2,b1,b2:longint;

procedure enter;
var i,j,u:longint;
    ch,cc:char;
begin
assign(f,fi);assign(g,fo);
reset(f);rewrite(g);
   read(f,ch,u,cc);
   s1:=ord(ch)-ord('a')+1;
   t1:=u;
   read(f,ch,u,cc);
   s2:=ord(ch)-ord('a')+1;
   t2:=u;
   read(f,ch,u,cc);
   w1:=ord(ch)-ord('a')+1;
   w2:=u;
   read(f,ch,u);
   b1:=ord(ch)-ord('a')+1;
   b2:=u;
end;

procedure process;
var i,j,u,v:longint;
begin
fillchar(a,sizeof(a),255);
fillchar(c,sizeof(c),0);
for i:=1 to 8 do
 for j:=1 to 8 do a[i,j]:=0;
a[w1,w2]:=-1;
c[b1,b2]:=2;
for i:=-1 to 1 do
 for j:=-1 to 1 do
  c[b1+i,b2+j]:=2;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  dec(u);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  inc(u);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  dec(v);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  inc(v);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  dec(u);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  inc(u);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  dec(v);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  inc(v);
  c[u,v]:=1;
 end;
 u:=0;
for i:=1 to 8 do
 for j:=1 to 8 do
  if c[i,j]=2 then u:=1;
if u=0 then writeln(g,'CHECKMATE')
else writeln(g,'OTHER');
end;

BEgin
    enter;
    process;
    close(g);
end.

program baib;

const   fi='';
        fo='';

var     f,g:text;
        a,c:array[0..10,0..10]of longint;
        s1,s2,t1,t2,w1,w2,b1,b2:longint;

procedure enter;
var i,j,u:longint;
    ch,cc:char;
begin
assign(f,fi);assign(g,fo);
reset(f);rewrite(g);
   read(f,ch,u,cc);
   s1:=ord(ch)-ord('a')+1;
   t1:=u;
   read(f,ch,u,cc);
   s2:=ord(ch)-ord('a')+1;
   t2:=u;
   read(f,ch,u,cc);
   w1:=ord(ch)-ord('a')+1;
   w2:=u;
   read(f,ch,u);
   b1:=ord(ch)-ord('a')+1;
   b2:=u;
end;

procedure process;
var i,j,u,v:longint;
begin
fillchar(a,sizeof(a),255);
fillchar(c,sizeof(c),0);
for i:=1 to 8 do
 for j:=1 to 8 do a[i,j]:=0;
a[w1,w2]:=-1;
c[b1,b2]:=2;
for i:=-1 to 1 do
 for j:=-1 to 1 do
 if a[b1+i,b2+j]<>-1 then
 begin
  c[b1+i,b2+j]:=2;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  dec(u);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  inc(u);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  dec(v);
  c[u,v]:=1;
 end;
u:=s1;v:=t1;
while a[u,v]<>-1 do
 begin
  inc(v);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  dec(u);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  inc(u);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  dec(v);
  c[u,v]:=1;
 end;
u:=s2;v:=t2;
while a[u,v]<>-1 do
 begin
  inc(v);
  c[u,v]:=1;
 end;
 u:=0;
for i:=1 to 8 do
 for j:=1 to 8 do
  if c[i,j]=2 then u:=1;
if u=0 then writeln(g,'CHECKMATE')
else writeln(g,'OTHER');
end;

BEgin
    enter;
    process;
    close(g);
end.

type res= record
          x,y:longint;
          end;
var n,i,j,k,code:integer;
    f1,f2,f3,f4:boolean;
    s:string;
    kor:array[1..4]Of res;
Function BK(x1,y1,x2,y2:longint):boolean;
Begin
     if (abs(x1-x2)<=1)and(abs(y1-y2)<=1)
     then bk:=false
     else bk:=true;
End;
Function WK(x1,y1,x2,y2,x3,y3:longint):boolean;
Begin
    if (x1=x2)and(y1=y2)
    then wk:=bk(x2,y2,x3,y3)
    else
    if (x1=x2) then
    begin
    if (x1=x3) then
    if (y3<y1)and(y2<y3)
     or(y3>y1)and(y2>y3)
     then wk:=false
     else wk:=true;
    end
     else wk:=false;
End;
Function Fi(x,y:longint):boolean;
Begin
     if (x<=0)or(y<=0)
      or(y>=9)or(x>=9)
     then fi:=true
     else
     begin
     if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)
     or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)
     then fi:=true
     else fi:=false;
     end;
End;
Begin
    readln(s);
    j:=1;
    For i:=1 to 11 do
    begin
         val(s[i],k,code);
         if k>0 then kor[j].y:=k;
         if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;
         if (i mod 3)=0 then inc(j);
    end;
    if fi(kor[4].x,kor[4].y)
    then begin
              if fi(kor[4].x+1,kor[4].y)and
                 fi(kor[4].x+1,kor[4].y+1)and
                 fi(kor[4].x,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y)and
                 fi(kor[4].x-1,kor[4].y-1)and
                 fi(kor[4].x,kor[4].y-1)and
                 fi(kor[4].x+1,kor[4].y-1)
                 then writeln('CHECKMATE')
                 else writeln('OTHER')
         end
     else writeln('OTHER');
End.

type res= record
          x,y:longint;
          end;
var n,i,j,k,code:integer;
    f1,f2,f3,f4:boolean;
    s:string;
    kor:array[1..4]Of res;
Function BK(x1,y1,x2,y2:longint):boolean;
Begin
     if (abs(x1-x2)<=1)and(abs(y1-y2)<=1)
     then bk:=true
     else bk:=false;
End;
Function WK(x1,y1,x2,y2,x3,y3:longint):boolean;
Begin
    if (x1=x2)and(y1=y2)
    then wk:=bk(x2,y2,x3,y3)
    else
    if (x1=x2) then
    begin
    if (x1=x3) then
    if (y3<y1)and(y2<y3)
     or(y3>y1)and(y2>y3)
     then wk:=false
     else wk:=true;
    end
     else wk:=false;
End;
Function Fi(x,y:longint):boolean;
Begin
     if (x<=0)or(y<=0)
      or(y>=9)or(x>=9)
     then fi:=true
     else
     begin
     if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)
     or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)
     then fi:=true
     else fi:=false;
     end;
End;
Begin
    readln(s);
    j:=1;
    For i:=1 to 11 do
    begin
         val(s[i],k,code);
         if k>0 then kor[j].y:=k;
         if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;
         if (i mod 3)=0 then inc(j);
    end;
    if fi(kor[4].x,kor[4].y)
    then begin
              if fi(kor[4].x+1,kor[4].y)and
                 fi(kor[4].x+1,kor[4].y+1)and
                 fi(kor[4].x,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y)and
                 fi(kor[4].x-1,kor[4].y-1)and
                 fi(kor[4].x,kor[4].y-1)and
                 fi(kor[4].x+1,kor[4].y-1)
                 then writeln('CHECKMATE')
                 else writeln('OTHER')
         end
     else writeln('OTHER');
End.

type res= record
          x,y:longint;
          end;
var n,i,j,k,code:integer;
    f1,f2,f3,f4:boolean;
    s:string;
    kor:array[1..4]Of res;
Function WK(x1,y1,x2,y2,x3,y3:longint):boolean;
Begin
    if (x1=x2)and(y1=y2)
    then wk:=WK(0,0,x2,y2,x3,y3)
    else
    if (x1=x2) then
    begin
    if (x1=x3) then
    if (y3<y1)and(y2<y3)
     or(y3>y1)and(y2>y3)
     then wk:=false
     else wk:=true;
    end
     else wk:=false;
End;
Function Fi(x,y:longint):boolean;
Begin
     if (x<=0)or(y<=0)
      or(y>=9)or(x>=9)
     then fi:=true
     else
     begin
     if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)
     or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)
     then fi:=true
     else fi:=false;
     end;
End;
Begin
    readln(s);
    j:=1;
    For i:=1 to 11 do
    begin
         val(s[i],k,code);
         if k>0 then kor[j].y:=k;
         if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;
         if (i mod 3)=0 then inc(j);
    end;
    if fi(kor[4].x,kor[4].y)
    then begin
              if fi(kor[4].x+1,kor[4].y)and
                 fi(kor[4].x+1,kor[4].y+1)and
                 fi(kor[4].x,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y)and
                 fi(kor[4].x-1,kor[4].y-1)and
                 fi(kor[4].x,kor[4].y-1)and
                 fi(kor[4].x+1,kor[4].y-1)
                 then writeln('CHECKMATE')
                 else writeln('OTHER')
         end
     else writeln('OTHER');
End.

type res= record
          x,y:longint;
          end;
var n,i,j,k,code:integer;
    f1,f2,f3,f4:boolean;
    s:string;
    kor:array[1..4]Of res;
Function WK(x1,y1,x2,y2,x3,y3:longint):boolean;
Begin
    if (x1=x2)and(y1=y2) then wk:=false
    else
    if (x1=x2) then
    begin
    if (x1=x3) then
    if (y3<y1)and(y2<y3)
     or(y3>y1)and(y2>y3)
     then wk:=false
     else wk:=true;
    end
     else wk:=false;
End;
Function Fi(x,y:longint):boolean;
Begin
     if (x<=0)and(y<=0)
     then fi:=true
     else
     if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)
     or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)
     then fi:=true
     else fi:=false;
End;
Begin
    readln(s);
    j:=1;
    For i:=1 to 11 do
    begin
         val(s[i],k,code);
         if k>0 then kor[j].y:=k;
         if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;
         if (i mod 3)=0 then inc(j);
    end;
    if fi(kor[4].x,kor[4].y)
    then begin
              if fi(kor[4].x+1,kor[4].y)and
                 fi(kor[4].x+1,kor[4].y+1)and
                 fi(kor[4].x,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y)and
                 fi(kor[4].x-1,kor[4].y-1)and
                 fi(kor[4].x,kor[4].y-1)and
                 fi(kor[4].x+1,kor[4].y-1)
                 then writeln('CHECKMATE')
                 else writeln('OTHER')
         end
     else writeln('OTHER');
End.

type res= record
          x,y:longint;
          end;
var n,i,j,k,code:integer;
    f1,f2,f3,f4:boolean;
    s:string;
    kor:array[1..4]Of res;
Function WK(x1,y1,x2,y2,x3,y3:longint):boolean;
Begin
    if (x1=x2)and(y1=y2) then wk:=false
    else
    if (x1=x2) then
    begin
    if (x1=x3) then
    if (y3<y1)and(y2<y3)
     or(y3>y1)and(y2>y3)
     then wk:=false
     else wk:=true;
    end
     else wk:=false;
End;
Function Fi(x,y:longint):boolean;
Begin
     if (x<=0)or(y<=0)
      or(y>=9)or(x>=9)
     then fi:=true
     else
     if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)
     or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)
     then fi:=true
     else fi:=false;
End;
Begin
    readln(s);
    j:=1;
    For i:=1 to 11 do
    begin
         val(s[i],k,code);
         if k>0 then kor[j].y:=k;
         if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;
         if (i mod 3)=0 then inc(j);
    end;
    if fi(kor[4].x,kor[4].y)
    then begin
              if fi(kor[4].x+1,kor[4].y)and
                 fi(kor[4].x+1,kor[4].y+1)and
                 fi(kor[4].x,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y)and
                 fi(kor[4].x-1,kor[4].y-1)and
                 fi(kor[4].x,kor[4].y-1)and
                 fi(kor[4].x+1,kor[4].y-1)
                 then writeln('CHECKMATE')
                 else writeln('OTHER')
         end
     else writeln('OTHER');
End.

type res= record
          x,y:longint;
          end;
var n,i,j,k,code:integer;
    f1,f2,f3,f4:boolean;
    s:string;
    kor:array[1..4]Of res;
Function WK(x1,y1,x2,y2,x3,y3:longint):boolean;
Begin
    if (x1=x2)and(y1=y2)
    then wk:=false
    else
    if (x1=x2) then
    begin
    if (x1=x3) then
    if (y3<y1)and(y2<y3)
     or(y3>y1)and(y2>y3)
     then wk:=false
     else wk:=true;
    end
     else wk:=false;
End;
Function Fi(x,y:longint):boolean;
Begin
     if (x<=0)or(y<=0)
      or(y>=9)or(x>=9)
     then fi:=true
     else
     begin
     if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)
     or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)
     then fi:=true
     else fi:=false;
     end;
End;
Begin
    readln(s);
    j:=1;
    For i:=1 to 11 do
    begin
         val(s[i],k,code);
         if k>0 then kor[j].y:=k;
         if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;
         if (i mod 3)=0 then inc(j);
    end;
    if fi(kor[4].x,kor[4].y)
    then begin
              if fi(kor[4].x+1,kor[4].y)and
                 fi(kor[4].x+1,kor[4].y+1)and
                 fi(kor[4].x,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y)and
                 fi(kor[4].x-1,kor[4].y-1)and
                 fi(kor[4].x,kor[4].y-1)and
                 fi(kor[4].x+1,kor[4].y-1)
                 then writeln('CHECKMATE')
                 else writeln('OTHER')
         end
     else writeln('OTHER');
End.

type res= record
          x,y:longint;
          end;
var n,i,j,k,code:integer;
    f1,f2,f3,f4:boolean;
    s:string;
    kor:array[1..4]Of res;
Function WK(x1,y1,x2,y2,x3,y3:longint):boolean;
Begin
    if (x1=x2)and(y1=y2) then wk:=false
    else
    if (x1=x2) then
    begin
    if (x1=x3) then
    if (y3<y1)and(y2<y3)
     or(y3>y1)and(y2>y3)
     then wk:=false
     else wk:=true;
    end
     else wk:=false;
End;
Function Fi(x,y:longint):boolean;
Begin
     if (x<=0)and(y<=0)
      or(x<=0)and(y>=9)
      or(x>=9)and(y<=0)
      or(x>=9)and(y>=9)
     then fi:=true
     else
     if wk(kor[1].x,kor[1].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[2].x,kor[2].y,x,y,kor[3].x,kor[3].y)
     or wk(kor[1].y,kor[1].x,y,x,kor[3].y,kor[3].x)
     or wk(kor[2].y,kor[2].x,y,x,kor[3].y,kor[3].x)
     then fi:=true
     else fi:=false;
End;
Begin
    readln(s);
    j:=1;
    For i:=1 to 11 do
    begin
         val(s[i],k,code);
         if k>0 then kor[j].y:=k;
         if (i mod 3)=1 then kor[j].x:=ord(s[i])-96;
         if (i mod 3)=0 then inc(j);
    end;
    if fi(kor[4].x,kor[4].y)
    then begin
              if fi(kor[4].x+1,kor[4].y)and
                 fi(kor[4].x+1,kor[4].y+1)and
                 fi(kor[4].x,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y+1)and
                 fi(kor[4].x-1,kor[4].y)and
                 fi(kor[4].x-1,kor[4].y-1)and
                 fi(kor[4].x,kor[4].y-1)and
                 fi(kor[4].x+1,kor[4].y-1)
                 then writeln('CHECKMATE')
                 else writeln('OTHER')
         end
     else writeln('OTHER');
End.

program     CFR41_A;
uses
    math;

const
    nfin=   '';
    nfout=  '';
    maxn=   30;
    vt:array[1..4,1..2] of longint=((0, 1), (1, 0), (-1, 0), (0, -1));

var
    d1, c1, d2, c2, d3, c3, d4, c4, u, v, i: longint;
    k1, k2, k3: char;
    fin, fout:  text;

function check(u, v: longint): boolean;
begin
    if ((u<>d1) and (v=c1))then begin
        if c3<>c1 then begin
            check:=true;
            exit;
        end;

        if ((d3<min(d1, u)) or (d3>max(u, d1))) then begin
            check:=true;
            exit;
        end;
    end;

    if ((u=d1) and (v<>c1))then begin
        if d3<>d1 then begin
            check:=(true);
            exit;
        end;
        if ((c3<min(c1, v)) or (c3>max(v, c1))) then begin
            check:=true;
            exit;
        end;
    end;

     if ((u<>d2) and (v=c2))then begin
        if c3<>c2 then begin
            check:=true;
            exit;
        end;

        if ((d3<min(d2, u)) or (d3>max(u, d2))) then begin
            check:=true;
            exit;
        end;
     end;

    if ((u=d2) and (v<>c2))then begin
        if d3<>d2 then begin
            check:=true;
            exit;
        end;
        if ((c3<min(c2, v)) or (c3>max(v, c2))) then begin
            check:=true;
            exit;
        end;
    end;

    if (abs(u-d3) + abs(v-c3) = 1) then begin
        check:=true;
        exit;
        end;
    check:=false;
end;

begin
    assign(fin, nfin); reset(fin);
    assign(fout, nfout); rewrite(fout);
    read(fin, k1, k2);
    d1:=ord(k1) - ord('a') + 1;
    c1:=ord(k2) - ord('0');

    read(fin, k3, k1, k2);
    d2:=ord(k1) - ord('a') + 1;
    c2:=ord(k2) - ord('0');

    read(fin,k3, k1, k2);
    d3:=ord(k1) - ord('a') + 1;
    c3:=ord(k2) - ord('0');

    read(fin,k3, k1, k2);
    d4:=ord(k1) - ord('a') + 1;
    c4:=ord(k2) - ord('0');

    if not check(d4, c4) then begin
        writeln(fout, 'OTHER');
        close(fout);
        close(fin);
        halt;
    end;

    for i:=1 to 4 do begin
        u:=d4+vt[i, 1];
        v:=c4+vt[i, 2];
        if (0<v) and (v<=8) and (0<u) and (u<=8) then begin
            if not check(u, v) then begin
                writeln(fout, 'OTHER');
                close(fout);
                close(fin);
                halt;
            end;
        end;
    end;

    writeln(fout, 'CHECKMATE');
    close(fout);
    close(fin);
end.

program     CFR41_A;
uses
    math;

const
    nfin=   '';
    nfout=  '';
    maxn=   30;
    vt:array[1..4,1..2] of longint=((0, 1), (1, 0), (-1, 0), (0, -1));

var
    d1, c1, d2, c2, d3, c3, d4, c4, u, v, i: longint;
    k1, k2, k3: char;
    fin, fout:  text;

begin
    assign(fin, nfin); reset(fin);
    assign(fout, nfout); rewrite(fout);
    read(fin, k1, k2);
    d1:=ord(k1) - ord('a') + 1;
    c1:=ord(k2) - ord('0');

    read(fin, k3, k1, k2);
    d2:=ord(k1) - ord('a') + 1;
    c2:=ord(k2) - ord('0');

    read(fin,k3, k1, k2);
    d3:=ord(k1) - ord('a') + 1;
    c3:=ord(k2) - ord('0');

    read(fin,k3, k1, k2);
    d4:=ord(k1) - ord('a') + 1;
    c4:=ord(k2) - ord('0');

    if (c4<>c1) and (d4<>d1) and (c4<>c2) and (d4<>d2) then begin
        writeln(fout, 'OTHER');
        close(fout);
        close(fin);
        halt;
    end;

    for i:=1 to 4 do begin
        u:=d4+vt[i, 1];
        v:=c4+vt[i, 2];
        if (0<v) and (v<=8) and (0<u) and (u<=8) then begin
            if not (
            (abs(u-d3)+abs(v-c3)=1)
            or (((u<>d1) and (v=c1)) or ((u=d1) and (v<>c1)))
            or (((u<>d2) and (v=c2)) or ((u=d2) and (v<>c2))) ) then begin
                writeln(fout, 'OTHER');
                close(fout);
                close(fin);
                halt;
            end;
        end;
    end;

    writeln(fout, 'CHECKMATE');
    close(fout);
    close(fin);
end.

program     CFR41_A;
uses
    math;

const
    nfin=   '';
    nfout=  '';
    maxn=   30;
    vt:array[1..4,1..2] of longint=((0, 1), (1, 0), (-1, 0), (0, -1));

var
    d1, c1, d2, c2, d3, c3, d4, c4, u, v, i: longint;
    k1, k2, k3: char;
    fin, fout:  text;

function check(u, v: longint): boolean;
begin
    if ((u<>d1) and (v=c1))then begin
        if c3<>c1 then begin
            check:=true;
            exit;
        end;

        if ((d3<min(d1, d4)) or (d3>max(d4, d1))) then begin
            check:=true;
            exit;
        end;
    end;

    if ((u=d1) and (v<>c1))then begin
        if d3<>d1 then begin
            check:=(true);
            exit;
        end;
        if ((c3<min(c1, c4)) or (c3>max(c4, c1))) then begin
            check:=true;
            exit;
        end;
    end;

     if ((u<>d2) and (v=c2))then begin
        if c3<>c2 then begin
            check:=true;
            exit;
        end;

        if ((d3<min(d2, d4)) or (d3>max(d4, d2))) then begin
            check:=true;
            exit;
        end;
     end;

    if ((u=d2) and (v<>c2))then begin
        if d3<>d2 then begin
            check:=true;
            exit;
        end;
        if ((c3<min(c2, c4)) or (c3>max(c4, c2))) then begin
            check:=true;
            exit;
        end;
    end;

    if (abs(u-d3) + abs(v-c3) = 1) then begin
        check:=true;
        exit;
        end;
    check:=false;
end;

begin
    assign(fin, nfin); reset(fin);
    assign(fout, nfout); rewrite(fout);
    read(fin, k1, k2);
    d1:=ord(k1) - ord('a') + 1;
    c1:=ord(k2) - ord('0');

    read(fin, k3, k1, k2);
    d2:=ord(k1) - ord('a') + 1;
    c2:=ord(k2) - ord('0');

    read(fin,k3, k1, k2);
    d3:=ord(k1) - ord('a') + 1;
    c3:=ord(k2) - ord('0');

    read(fin,k3, k1, k2);
    d4:=ord(k1) - ord('a') + 1;
    c4:=ord(k2) - ord('0');

    if not check(d4, c4) then begin
        writeln(fout, 'OTHER');
        close(fout);
        close(fin);
        halt;
    end;

    for i:=1 to 4 do begin
        u:=d4+vt[i, 1];
        v:=c4+vt[i, 2];
        if (0<v) and (v<=8) and (0<u) and (u<=8) then begin
            if not check(u, v) then begin
                writeln(fout, 'OTHER');
                close(fout);
                close(fin);
                halt;
            end;
        end;
    end;

    writeln(fout, 'CHECKMATE');
    close(fout);
    close(fin);
end.

program CF_GameOfChessUnfinished;
var
        x,y,p:char;
        a,b,c,d,e,f,g,h,i,j:integer;
        mark:array[0..9,0..9] of boolean;
        ima,t:boolean;
begin
        for i:=0 to 9 do
          for j:=0 to 9 do mark[i,j]:=true;
        for i:=1 to 8 do
          for j:=1 to 8 do mark[i,j]:=false;
        read(x,y,p);
        a:=ord(x)-96;
        b:=ord(y)-48;
        read(x,y,p);
        c:=ord(x)-96;
        d:=ord(y)-48;
        read(x,y,p);
        e:=ord(x)-96;
        f:=ord(y)-48;
        read(x,y);
        readln;
        g:=ord(x)-96;
        h:=ord(y)-48;
        //t:=mark[a,b];
        for i:=a+1 to 8 do
          if (i=e) and (b=f) then break
          else mark[i,b]:=true;
        for i:=a-1 downto 1 do
          if (i=a) and (b=f) then break
          else mark[i,b]:=true;
        for i:=b+1 to 8 do
          if (a=e) and (i=f) then break
          else mark[a,i]:=true;
        for i:=b-1 downto 1 do
          if (a=e) and (i=f) then break
          else mark[a,i]:=true;

        for i:=c+1 to 8 do
          if (i=e) and (d=f) then break
          else mark[i,d]:=true;
        for i:=c-1 downto 1 do
          if (i=c) and (d=f) then break
          else mark[i,d]:=true;
        for i:=d+1 to 8 do
          if (c=e) and (i=f) then break
          else mark[c,i]:=true;
        for i:=d-1 downto 1 do
          if (c=e) and (i=f) then break
          else mark[c,i]:=true;

        mark[e,f+1]:=true;
        mark[e,f-1]:=true;
        mark[e-1,f]:=true;
        mark[e+1,f]:=true;
        mark[e+1,f+1]:=true;
        mark[e+1,f-1]:=true;
        mark[e-1,f+1]:=true;
        mark[e-1,f-1]:=true;

        ima:=not(mark[g,h+1]) or not(mark[g,h-1]) or not(mark[g+1,h]) or not(mark[g-1,h]) or not(mark[g+1,h+1]) or not(mark[g+1,h-1]) or not(mark[g-1,h+1]) or not(mark[g-1,h-1]);
        if not(ima) and mark[g,h] then writeln('CHECKMATE')
        else writeln('OTHER');
end.

var
 a,b:array[0..9,0..9] of char;
  x,y,i,j:longint;
   answer:boolean;
    s:string;

procedure proverka(var rez:boolean);
var i,j,x,y:longint;
 begin
  rez:=true;
   for i:=1 to 8 do
    for j:=1 to 8 do
     if b[i,j]<>'.'
      then
       begin
        if b[i,j]='L'
         then
          begin
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               inc(x);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               dec(x);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               inc(y);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               dec(y);
             end;
          end;
        if b[i,j]='W'
         then
          begin
           if (b[i-1,j-1]='B') or (b[i-1,j]='B') or (b[i-1,j+1]='B') or (b[i,j-1]='B') or (b[i,j+1]='B') or (b[i+1,j-1]='B') or (b[i+1,j]='B') or (b[i+1,j+1]='B')
            then
             begin
              exit;
             end;
          end;
       end;
  rez:=false;
 end;

procedure untilprogram;
var i,j:longint;
 begin
  for i:=1 to 8 do
   for j:=1 to 8 do
  a[i,j]:='.';
  for i:=0 to 9 do
   begin
    a[i,0]:='#';
     a[i,9]:='#';
     a[0,i]:='#';
    a[9,i]:='#';
   end;
 end;

begin

  untilprogram;
   readln(s);
    x:=ord(s[1])-96;
     y:=9-(ord(s[2])-48);
    a[x,y]:='L';
    x:=ord(s[4])-96;
     y:=9-(ord(s[5])-48);
    a[x,y]:='L';
    x:=ord(s[7])-96;
     y:=9-(ord(s[8])-48);
    a[x,y]:='W';
    x:=ord(s[10])-96;
     y:=9-(ord(s[11])-48);
    a[x,y]:='B';
   proverka(answer);
    if answer = false
     then
      begin
       writeln('OTHER');
        halt;
      end
     else
      begin
       for i:=-1 to 1 do
        for j:=-1 to 1 do
         if (i<>0) and (j<>0) and (x+i>=1) and (x+i<=8) and (y+j>=1) and (y+j<=8)
          then
           begin
            b:=a;
             b[x,y]:='.'; b[x+i,y+j]:='B';
              proverka(answer);
             if answer = false
              then
               begin
                writeln('OTHER');
                 halt;
               end;
           end;
      end;
  writeln('CHECKMATE');

end.

var
 a,b:array[0..9,0..9] of char;
  x,y,i,j:longint;
   answer:boolean;
    s:string;

procedure proverka(var rez:boolean);
var i,j,x,y:longint;
 begin
  rez:=true;
   for i:=1 to 8 do
    for j:=1 to 8 do
     if b[i,j]<>'.'
      then
       begin
        if b[i,j]='L'
         then
          begin
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               inc(x);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               dec(x);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               inc(y);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               dec(y);
             end;
          end;
        if b[i,j]='W'
         then
          begin
           if (b[i-1,j-1]='B') or (b[i-1,j]='B') or (b[i-1,j+1]='B') or (b[i,j-1]='B') or (b[i,j+1]='B') or (b[i+1,j-1]='B') or (b[i+1,j]='B') or (b[i+1,j+1]='B')
            then
             begin
              exit;
             end;
          end;
       end;
  rez:=false;
 end;

procedure untilprogram;
var i,j:longint;
 begin
  for i:=1 to 8 do
   for j:=1 to 8 do
  a[i,j]:='.';
  for i:=0 to 9 do
   begin
    a[i,0]:='#';
     a[i,9]:='#';
     a[0,i]:='#';
    a[9,i]:='#';
   end;
 end;

begin

  untilprogram;
   readln(s);
    x:=ord(s[1])-96;
     y:=9-(ord(s[2])-48);
    a[x,y]:='L';
    x:=ord(s[4])-96;
     y:=9-(ord(s[5])-48);
    a[x,y]:='L';
    x:=ord(s[7])-96;
     y:=9-(ord(s[8])-48);
    a[x,y]:='W';
    x:=ord(s[10])-96;
     y:=9-(ord(s[11])-48);
    a[x,y]:='B';
   b:=a;
   proverka(answer);
    if answer = false
     then
      begin
       writeln('OTHER');
        halt;
      end
     else
      begin
       for i:=-1 to 1 do
        for j:=-1 to 1 do
         if not((i=0) and (j=0)) and (x+i>=1) and (x+i<=8) and (y+j>=1) and (y+j<=8)
          then
           begin
            b:=a;
             b[x,y]:='.'; b[x+i,y+j]:='B';
              proverka(answer);
             if answer = false
              then
               begin
                writeln('OTHER');
                 halt;
               end;
           end;
      end;
  writeln('CHECKMATE');

end.

var
 a,b:array[0..9,0..9] of char;
  x,y,i,j:longint;
   answer:boolean;
    s:string;

procedure proverka(var rez:boolean);
var i,j,x,y:longint;
 begin
  rez:=true;
   for i:=1 to 8 do
    for j:=1 to 8 do
     if b[i,j]<>'.'
      then
       begin
        if b[i,j]='L'
         then
          begin
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               inc(x);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               dec(x);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               inc(y);
             end;
           x:=i; y:=j;
            while b[x,y]<>'#' do
             begin
              if b[x,y]='B' then exit;
               dec(y);
             end;
          end;
        if b[i,j]='W'
         then
          begin
           if (b[i-1,j-1]='B') or (b[i-1,j]='B') or (b[i-1,j+1]='B') or (b[i,j-1]='B') or (b[i,j+1]='B') or (b[i+1,j-1]='B') or (b[i+1,j]='B') or (b[i+1,j+1]='B')
            then
             begin
              exit;
             end;
          end;
       end;
  rez:=false;
 end;

procedure untilprogram;
var i,j:longint;
 begin
  for i:=1 to 8 do
   for j:=1 to 8 do
  a[i,j]:='.';
  for i:=0 to 9 do
   begin
    a[i,0]:='#';
     a[i,9]:='#';
     a[0,i]:='#';
    a[9,i]:='#';
   end;
 end;

begin

  untilprogram;
   readln(s);
    x:=ord(s[1])-96;
     y:=9-(ord(s[2])-48);
    a[x,y]:='L';
    x:=ord(s[4])-96;
     y:=9-(ord(s[5])-48);
    a[x,y]:='L';
    x:=ord(s[7])-96;
     y:=9-(ord(s[8])-48);
    a[x,y]:='W';
    x:=ord(s[10])-96;
     y:=9-(ord(s[11])-48);
    a[x,y]:='B';
   b:=a;
   proverka(answer);
    if answer = false
     then
      begin
       writeln('OTHER');
        halt;
      end
     else
      begin
       for i:=-1 to 1 do
        for j:=-1 to 1 do
         if (i<>0) and (j<>0) and (x+i>=1) and (x+i<=8) and (y+j>=1) and (y+j<=8)
          then
           begin
            b:=a;
             b[x,y]:='.'; b[x+i,y+j]:='B';
              proverka(answer);
             if answer = false
              then
               begin
                writeln('OTHER');
                 halt;
               end;
           end;
      end;
  writeln('CHECKMATE');

end.

Program z42b;
type byte=integer;
const xx:array[1..8]of shortint=(-1,-1,0,1,1,1,0,-1);
	yy:array[1..8]of shortint=(0,1,1,1,0,-1,-1,-1);
var a,c:array[0..9,0..9]of byte;
	b:array[1..2,1..4]of byte;
	x,y,i,x1,y1,j:byte;
    cc:char;
begin
	j:=1;
	for i:=2 to 3 do
    begin
    	read(cc);
        x:=ord(cc)-ord('a')+1;
        read(y);
        c[y,x]:=i;
        b[1,j]:=x;
        b[2,j]:=y;
        inc(j);
        read(cc);
        read(cc);
        x1:=ord(cc)-ord('a')+1;
        read(y1);
        c[y1,x1]:=i;
        read(cc);
        b[1,j]:=x1;
        b[2,j]:=y1;
        inc(j);
    end;
    for i:=0 to 9 do
    begin
    	a[i,0]:=1;
        a[i,9]:=1;
        a[0,i]:=1;
        a[9,i]:=1;
    end;
    for i:=1 to 2 do
    begin
    	j:=b[1,i]+1;
        while (j<=8)and(c[b[2,i],j]<3) do
        begin
            a[b[2,i],j]:=1;
            inc(j);
        end;
        a[b[2,i],j]:=1;
        j:=b[1,i]-1;
        while (j>0)and(c[b[2,i],j]<3) do
        begin
        	a[b[2,i],j]:=1;
            dec(j);
        end;
        a[b[2,i],j]:=1;
        j:=b[2,i]+1;
        while (j<=8)and(c[j,b[1,i]]<3) do
        begin
        	a[j,b[1,i]]:=1;
            inc(j);
        end;
        a[j,b[1,i]]:=1;
        j:=b[2,i]-1;
        while (j>0)and(c[j,b[1,i]]<3) do
        begin
        	a[j,b[1,i]]:=1;
            dec(j);
        end;
        a[j,b[1,i]]:=1;
    end;
    for i:=1 to 8 do
    	a[y+yy[i],x+xx[i]]:=1;
    if a[y1,x1]=1
    then
    begin
    	for i:=1 to 8 do
    	  	if a[y1+yy[i],x1+xx[i]]=0 then begin write('OTHER');halt;end;
        write('CHECKMATE');
    end
    else write('OTHER');
end.

Program z42b;
const xx:array[1..8]of shortint=(-1,-1,0,1,1,1,0,-1);
	yy:array[1..8]of shortint=(0,1,1,1,0,-1,-1,-1);
var a:array[0..9,0..9]of byte;
	b:array[1..2,1..4]of byte;
	x,y,i,x1,y1,j:byte;
    c:char;
begin
	j:=1;
	for i:=2 to 3 do
    begin
    	read(c);
        x:=ord(c)-ord('a')+1;
        read(y);
        {c[y,x]:=i;}
        b[1,j]:=x;
        b[2,j]:=y;
        inc(j);
        read(c);
        read(c);
        x1:=ord(c)-ord('a')+1;
        read(y1);
        {c[y1,x1]:=i;}
        read(c);
        b[1,j]:=x1;
        b[2,j]:=y1;
        inc(j);
    end;
    for i:=0 to 9 do
    begin
    	a[i,0]:=1;
        a[i,9]:=1;
        a[0,i]:=1;
        a[9,i]:=1;
    end;
    for i:=1 to 2 do
    begin
    	for j:=1 to 8 do
        begin
        	if j<>b[2,i] then a[j,b[1,i]]:=1;
            if j<>b[1,i] then a[b[2,i],j]:=1;
        end;
    end;
    for i:=1 to 8 do
    	a[y+yy[i],x+xx[i]]:=1;
    if a[y1,x1]=1
    then
    begin
    	for i:=1 to 8 do
    	  	if a[y1+yy[i],x1+xx[i]]=0 then begin write('OTHER');halt;end;
        write('CHECKMATE');
    end
    else write('OTHER');
end.

Program z42b;
type byte=integer;
const xx:array[1..8]of shortint=(-1,-1,0,1,1,1,0,-1);
	yy:array[1..8]of shortint=(0,1,1,1,0,-1,-1,-1);
var a,c:array[0..9,0..9]of byte;
	b:array[1..2,1..4]of byte;
	x,y,i,x1,y1,j:byte;
    cc:char;
begin
	j:=1;
	for i:=3 downto 2 do
    begin
    	read(cc);
        x:=ord(cc)-ord('a')+1;
        read(y);
        c[y,x]:=i;
        b[1,j]:=x;
        b[2,j]:=y;
        inc(j);
        read(cc);
        read(cc);
        x1:=ord(cc)-ord('a')+1;
        read(y1);
        c[y1,x1]:=i;
        read(cc);
        b[1,j]:=x1;
        b[2,j]:=y1;
        inc(j);
    end;
    for i:=0 to 9 do
    begin
    	a[i,0]:=1;
        a[i,9]:=1;
        a[0,i]:=1;
        a[9,i]:=1;
    end;
    for i:=1 to 2 do
    begin
    	j:=b[1,i]+1;
        while (j<=8)and(c[b[2,i],j]<3) do
        begin
            a[b[2,i],j]:=1;
            inc(j);
        end;
        a[b[2,i],j]:=1;
        j:=b[1,i]-1;
        while (j>0)and(c[b[2,i],j]<3) do
        begin
        	a[b[2,i],j]:=1;
            dec(j);
        end;
        a[b[2,i],j]:=1;
        j:=b[2,i]+1;
        while (j<=8)and(c[j,b[1,i]]<3) do
        begin
        	a[j,b[1,i]]:=1;
            inc(j);
        end;
        a[j,b[1,i]]:=1;
        j:=b[2,i]-1;
        while (j>0)and(c[j,b[1,i]]<3) do
        begin
        	a[j,b[1,i]]:=1;
            dec(j);
        end;
        a[j,b[1,i]]:=1;
    end;
    for i:=1 to 8 do
    	a[y+yy[i],x+xx[i]]:=1;
    if a[y1,x1]=1
    then
    begin
    	for i:=1 to 8 do
    	  	if a[y1+yy[i],x1+xx[i]]=0 then begin write('OTHER');halt;end;
        write('CHECKMATE');
    end
    else write('OTHER');
end.

var a,b:array[0..9,0..9]of byte;
    i,x,y,j,k:longint;
    ch:char;
    by:byte;
    s:string;
begin
 fillchar(a,sizeof(a),0);
 fillchar(b,sizeof(b),0);
 for i:=0 to 9 do begin
  a[0,i]:=1; a[i,0]:=1;
  a[9,i]:=1; a[i,9]:=1;
 end;
 for i:=1 to 3 do begin
  read(ch);read(by);
  x:=ord(ch)-ord('a')+1;
  y:=by;
  read(ch);
  if i<3 then begin
   b[x,y]:=1;
   for j:=1 to 8 do begin inc(a[x,j]); inc(a[j,y]); end;
  end else begin
   for j:=x-1 to x+1 do
    for k:=y-1 to y+1 do
     inc(a[j,k]);
  end;
 end;
  s:='CHECKMATE';
  read(ch);read(by);
  x:=ord(ch)-ord('a')+1;
  y:=by;
  for i:=x-1 to x+1 do
   for j:=y-1 to y+1 do begin
    if (a[i,j]=0)or((a[i,j]=2) and (b[i,j]=1)) then s:='OTHER';
    end;
  writeln(s);

end.

{$apptype console}

type Tpos = record x, y : integer; end;

procedure readpos( var p : TPos );
var ch :char;
begin
  read(ch );
  while not (ch in ['a'..'h']) do read( ch );
  p.y := ord(ch) - ord('a' ) + 1;
  read(ch);
  p.x := ord(ch) - ord('0');
end;

var l1,l2, wk : TPos;

function beaten( xx, yy : integer ): boolean;
begin
   result := false;
   if (xx<>l1.x) or( yy<>l1.y) then begin
      if (l1.x = xx) or (l1.y =yy) then begin
         result := true;
         exit;
      end;
   end;
   if (xx<>l2.x) or( yy<>l2.y) then begin
      if (l2.x = xx) or (l2.y =yy) then begin
         result := true;
         exit;
      end;
   end;
   if (xx<>wk.x) or( yy<>wk.y) then begin
      if (abs(wk.x - xx)<=1) and (abs(wk.y-yy) <= 1) then begin
         result := true;
         exit;
      end;
   end;
end;

const v : array [1..8, 1..2] of integer =
((1,0),(-1,0),(0,1),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1));
var bk  : TPos;
    i, xx,yy : integer;
begin
{  reset( input, 'in.txt' );}
{}
   ReadPos( l1 );
   ReadPos( l2 );
   ReadPos( wk );
   ReadPos( bk );
{}
   if not beaten( bk.x, bk.y ) then begin
         writeln( 'OTHER' );
         exit;
   end;
   for i := 1 to 9 do begin
      xx := bk.x + v[i,1];
      yy := bk.y + v[i,2];
      if (xx<1) or (xx>8) or ( yy<1) or (yy>8) then
         continue;
      if not beaten( xx, yy ) then begin
         writeln( 'OTHER' );
         exit;
      end;
   end;
   writeln( 'CHECKMATE');
end.

{$apptype console}

type Tpos = record x, y : integer; end;

procedure readpos( var p : TPos );
var ch :char;
begin
  read(ch );
  while not (ch in ['a'..'h']) do read( ch );
  p.y := ord(ch) - ord('a' ) + 1;
  read(ch);
  p.x := ord(ch) - ord('0');
end;

var l1,l2, wk : TPos;

function inner( x,a,b : integer ) : boolean;
var t : integer;
begin
  if a > b then begin t := a; a:=b; b := t; end;
  result := (x>a) and (x<b );
end;

function lb( const lp :Tpos; xx, yy : integer ) : boolean;
begin
   result := false;
   if( lp.x = xx) and (lp.y=yy) then exit;
{}
   if(lp.x = xx ) then begin
      if not inner( wk.y, yy, lp.y ) then begin
         result := true;
         exit;
      end;
   end;
{}
   if(lp.y = yy ) then begin
      if not inner( wk.x, xx, lp.x ) then begin
         result := true;
         exit;
      end;
   end;
end;

function beaten( xx, yy : integer ): boolean;
begin
   result := false;
   if lb(l1,xx,yy) or lb(l2,xx,yy) then begin
      result := true;
      exit;
   end;
   if (xx<>wk.x) or( yy<>wk.y) then begin
      if (abs(wk.x - xx)<=1) and (abs(wk.y-yy) <= 1) then begin
         result := true;
         exit;
      end;
   end;
end;

const v : array [1..8, 1..2] of integer =
((1,0),(-1,0),(0,1),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1));
var bk  : TPos;
    i, xx,yy : integer;
begin
{  reset( input, 'in.txt' );}
{}
   ReadPos( l1 );
   ReadPos( l2 );
   ReadPos( wk );
   ReadPos( bk );
{}
   if not beaten( bk.x, bk.y ) then begin
         writeln( 'OTHER' );
         exit;
   end;
   for i := 1 to 9 do begin
      xx := bk.x + v[i,1];
      yy := bk.y + v[i,2];
      if (xx<1) or (xx>8) or ( yy<1) or (yy>8) then
         continue;
      if not beaten( xx, yy ) then begin
         writeln( 'OTHER' );
         exit;
      end;
   end;
   writeln( 'CHECKMATE');
end.

{ uses crt;}
 const nn=50;
    type mas=array [0..nn] of longint;
    var i1,j1,ot,n,i,j,k,il,p,imin,m,lengtha,shag:longint;
    l1,l2,wk,bk,nk:mas;
   s:real;
       a,b,pr:mas;
       ll1,ll2,wwk,bbk,ll3:char;
      boypol,boy:boolean;

  function boyl1(i,j:longint):boolean; var bb1,bb2:boolean;
begin
 bb1:=false;
 if l1[1]=i then begin bb1:=true;
 if wk[1]=i then if ((wk[2]-l1[2])*(wk[2]-j)<0)
 then begin bb1:=false; {write('aaa');} end;
 end;
{ writeln('bb1',bb1);}

 bb2:=false;
 if l1[2]=j then begin bb2:=true;
 if wk[2]=j then if ((wk[1]-l1[1])*(wk[1]-i)<0)
 then begin bb2:=false; {write('bbb');} end;
 end;

{ writeln('bb2',bb2); }

boyl1:=bb1 or bb2;  if (i=l1[1])and(j=l1[2]) then boyl1:=false;

end;

  function boyl2(i,j:longint):boolean; var bb1,bb2:boolean;
begin
 bb1:=false;
 if l2[1]=i then begin bb1:=true;
 if wk[1]=i then if ((wk[2]-l2[2])*(wk[2]-j)<0) then bb1:=false; end;
{ writeln('rrr',bb1); }

 bb2:=false;
 if l2[2]=j then begin bb2:=true;
 if wk[2]=j then if ((wk[1]-l2[1])*(wk[1]-i)<0) then bb2:=false; end;

{ writeln('www',bb2); }

boyl2:=bb1 or bb2;

if (i=l2[1])and(j=l2[2]) then boyl2:=false;

end;

 function boyk(i,j:longint):boolean; var bb1,bb2:boolean;
  begin
       bb1:=false; if (abs(i-wk[1])<=1) and(abs(j-wk[2])<=1)  then bb1:=true;
    boyk:=bb1;
  end;

     begin  {  clrscr;
     assign(input,'input.txt'); reset (input); }
         {  assign(output,'digitsum.out'); rewrite (output); }
       read(ll1);read(ll2);read(ll3);
       l1[1]:=ord(ll1)-96;
       l1[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       l2[1]:=ord(ll1)-96;
       l2[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       wk[1]:=ord(ll1)-96;
       wk[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       bk[1]:=ord(ll1)-96;
       bk[2]:=ord(ll2)-48;

      { write(l1[1],' ',l1[2],' ',l2[1],' ',l2[2],' ',wk[1],' ',wk[2],' ',bk[1],' ',bk[2],' ');
        }
{        boy:=true;
  for i:=-1 to 1 do
  for j:=-1 to 1 do
  if ((bk[1]+i)>=1)and((bk[1]+i)<=8)and((bk[2]+j)>=1)and((bk[2]+j)<=8) then
     begin  boypol:=false;
     nk[1]:=bk[1]+i; nk[2]:=bk[2]+j; i1:=nk[1];j1:=nk[2];
       if boyl1(i1,j1)or boyl2(i1,j1) or boyk(i1,j1)  then boypol:=true;
       if not boypol then boy:=false;

     end; }

 {    writeln;
     for i:=1 to 8 do
     begin for j:=1 to 8 do if boyl1(i,j)
     then write('+') else write('-');writeln; end;
  }
  { writeln(boyl1(1,4)); }

  if boy then write('CHECKMATE') else write('OTHER');

           end.

{ uses crt; }
 const nn=50;
    type mas=array [0..nn] of longint;
    var i1,j1,ot,n,i,j,k,il,p,imin,m,lengtha,shag:longint;
    l1,l2,wk,bk,nk:mas;
   s:real;
       a,b,pr:mas;
       ll1,ll2,wwk,bbk,ll3:char;
      boypol,boy:boolean;

  function boyl1(i,j:longint):boolean; var bb1,bb2:boolean;
begin
 bb1:=false;
 if l1[1]=i then begin bb1:=true;
 if wk[1]=i then if ((wk[2]-l1[2])*(wk[2]-bk[2])>0)
 then begin bb1:=false; {write('aaa');} end;
 end;
{ writeln('rrr',bb1);}

 bb2:=false;
 if l1[2]=j then begin bb2:=true;
 if wk[2]=j then if ((wk[1]-l1[1])*(wk[1]-bk[1])>0)
 then begin bb2:=false;{ write('bbb');} end;
 end;

{ writeln('www',bb2);}

boyl1:=bb1 or bb2;  if (i=l1[1])and(j=l1[2]) then boyl1:=false;

end;

  function boyl2(i,j:longint):boolean; var bb1,bb2:boolean;
begin
 bb1:=false;
 if l2[1]=i then begin bb1:=true;
 if wk[1]=i then if ((wk[2]-l2[2])*(wk[2]-bk[2])>0) then bb1:=false; end;
{ writeln('rrr',bb1); }

 bb2:=false;
 if l2[2]=j then begin bb2:=true;
 if wk[2]=j then if ((wk[1]-l2[1])*(wk[1]-bk[1])>0) then bb2:=false; end;

{ writeln('www',bb2); }

boyl2:=bb1 or bb2;

if (i=l2[1])and(j=l2[2]) then boyl2:=false;

end;

 function boyk(i,j:longint):boolean; var bb1,bb2:boolean;
  begin
       bb1:=false; if (abs(i-wk[1])<=1) and(abs(j-wk[2])<=1)  then bb1:=true;
    boyk:=bb1;
  end;

     begin   { clrscr;
     assign(input,'input.txt'); reset (input); }
         {  assign(output,'digitsum.out'); rewrite (output); }
       read(ll1);read(ll2);read(ll3);
       l1[1]:=ord(ll1)-96;
       l1[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       l2[1]:=ord(ll1)-96;
       l2[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       wk[1]:=ord(ll1)-96;
       wk[2]:=ord(ll2)-48;

       read(ll1);read(ll2);read(ll3);
       bk[1]:=ord(ll1)-96;
       bk[2]:=ord(ll2)-48;

      { write(l1[1],' ',l1[2],' ',l2[1],' ',l2[2],' ',wk[1],' ',wk[2],' ',bk[1],' ',bk[2],' ');
        }
        boy:=true;
  for i:=-1 to 1 do
  for j:=-1 to 1 do
  if ((bk[1]+i)>=1)and((bk[1]+i)<=8)and((bk[2]+j)>=1)and((bk[2]+j)<=8) then
     begin  boypol:=false;
     nk[1]:=bk[1]+i; nk[2]:=bk[2]+j; i1:=nk[1];j1:=nk[2];
       if boyl1(i1,j1)or boyl2(i1,j1) or boyk(i1,j1)  then boypol:=true;
       if not boypol then boy:=false;

     end;
   {  writeln;
     for j:=8 downto 1 do
     begin for i:=1 to 8 do if boyl1(i,j) then write('+') else write('-');writeln; end;
    }
  { writeln(boyl1(2,7)); }

  if boy then write('CHECKMATE') else write('OTHER');

           end.

program ProblemB;

{$APPTYPE CONSOLE}

var map : array [0..9, 0..9] of boolean;
    c : array [1..4, 1..2] of integer;
    ch : char;
    i, x, y, j : integer;
    ans : boolean;

begin
  for i := 1 to 4 do
  begin
    read(ch);
    c[i, 1] := ord(ch) - 96;
    read(ch);
    c[i, 2] := ord(ch) - 48;
    read(ch);
  end;

  for i := 0 to 9 do
    for j := 0 to 9 do
      map[i, j] := false;

  for i := 0 to 9 do
  begin
    map[i, 0] := true;
    map[i, 9] := true;
    map[0, i] := true;
    map[9, i] := true;
  end;

  x := c[1, 1];
  y := c[1, 2];
  for i := x + 1 to 8 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := x - 1 downto 1 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := y + 1 to 8 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;
  for i := y - 1 downto 1 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;

  //-------------------------------

  x := c[2, 1];
  y := c[2, 2];
  for i := x + 1 to 8 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := x - 1 downto 1 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := y + 1 to 8 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;
  for i := y - 1 downto 1 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;

  map[c[3, 2], c[3, 1]] := true;

  x := c[4, 1];
  y := c[4, 2];

  if ((not(map[y, x])) or (not(map[y + 1, x])) or (not(map[y - 1, x])) or (not(map[y, x + 1])) or (not(map[y, x - 1]))) then writeln('OTHER')
  else writeln('CHECKMATE');

  readln;
  readln;
end.

program ProblemB;

{$APPTYPE CONSOLE}

var map : array [0..9, 0..9] of boolean;
    c : array [1..4, 1..2] of integer;
    ch : char;
    i, x, y, j : integer;
    ans : boolean;

begin
  for i := 1 to 4 do
  begin
    read(ch);
    c[i, 1] := ord(ch) - 96;
    read(ch);
    c[i, 2] := ord(ch) - 48;
    read(ch);
  end;

  for i := 0 to 9 do
    for j := 0 to 9 do
      map[i, j] := false;

  for i := 0 to 9 do
  begin
    map[i, 0] := true;
    map[i, 9] := true;
    map[0, i] := true;
    map[9, i] := true;
  end;

  x := c[1, 1];
  y := c[1, 2];
  for i := x + 1 to 8 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := x - 1 downto 1 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := y + 1 to 8 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;
  for i := y - 1 downto 1 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;

  //-------------------------------

  x := c[2, 1];
  y := c[2, 2];
  for i := x + 1 to 8 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := x - 1 downto 1 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := y + 1 to 8 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;
  for i := y - 1 downto 1 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;

  map[c[3, 2], c[3, 1]] := true;

  x := c[4, 1];
  y := c[4, 2];

  if ((not(map[y, x])) or (not(map[y + 1, x])) or (not(map[y - 1, x])) or (not(map[y, x + 1])) or (not(map[y, x - 1]))) then writeln('OTHER')
  else writeln('CHEKMATE');

  readln;
  readln;
end.

program ProblemB;

{$APPTYPE CONSOLE}

var map : array [0..9, 0..9] of boolean;
    c : array [1..4, 1..2] of integer;
    ch : char;
    i, x, y, j : integer;
    ans : boolean;

begin
  for i := 1 to 4 do
  begin
    read(ch);
    c[i, 1] := ord(ch) - 96;
    read(ch);
    c[i, 2] := ord(ch) - 48;
    read(ch);
  end;

  for i := 0 to 9 do
    for j := 0 to 9 do
      map[i, j] := false;

  for i := 0 to 9 do
  begin
    map[i, 0] := true;
    map[i, 9] := true;
    map[0, i] := true;
    map[9, i] := true;
  end;

  x := c[1, 1];
  y := c[1, 2];
  for i := x + 1 to 8 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := x - 1 downto 1 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := y + 1 to 8 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;
  for i := y - 1 downto 1 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;

  //-------------------------------

  x := c[2, 1];
  y := c[2, 2];
  for i := x + 1 to 8 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := x - 1 downto 1 do
  begin
    if (y = c[3, 2]) and (i = c[3, 1]) then break;
    map[y, i] := true;
  end;
  for i := y + 1 to 8 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;
  for i := y - 1 downto 1 do
  begin
    if (i = c[3, 2]) and (x = c[3, 1]) then break;
    map[i, x] := true;
  end;

  map[c[3, 2], c[3, 1]] := true;

  x := c[4, 1];
  y := c[4, 2];

  if ((not(map[y, x])) or (not(map[y + 1, x])) or (not(map[y - 1, x])) or (not(map[y, x + 1])) or (not(map[y, x - 1]))) or (not(map[y + 1, x + 1])) or (not(map[y + 1, x - 1])) or (not(map[y - 1, x + 1])) or (not(map[y - 1, x - 1])) then writeln('OTHER')
  else writeln('CHECKMATE');

  readln;
  readln;
end.

program myw;

{$APPTYPE CONSOLE}

uses
  SysUtils;

  type Point = record
    x : longint;
    y : longint;
   end;

var i,j : longint;  s : char;
    a,b,c,d : point;
    mas : array[0..9,0..9] of longint;
begin
   read(s);
   a.x:=ord(s)-ord('a')+1;
   read(s);
   a.y:=ord(s)-ord('0');
   read(s);
   read(s);
   b.x:=ord(s)-ord('a')+1;
   read(s);
   b.y:=ord(s)-ord('0');
   read(s);
   read(s);
   c.x:=ord(s)-ord('a')+1;
   read(s);
   c.y:=ord(s)-ord('0');
   read(s);
   read(s);
   d.x:=ord(s)-ord('a')+1;
   read(s);
   d.y:=ord(s)-ord('0');
   for i:=1 to 8 do
    for j:=1 to 8 do
      mas[i,j]:=0;
   for i:=1 to 8 do
     begin
       inc(mas[i,a.y]);
       inc(mas[a.x,i]);
       inc(mas[i,b.y]);
       inc(mas[b.x,i]);
     end;
    mas[a.x,a.y]:=10;
    mas[b.x,b.y]:=10;
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          inc(mas[c.x+i,c.y+j]);
        end;
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)
             and ((mas[d.x+i,d.y+j]=0) or
               (  (mas[d.x+i,d.y+j]>10) and (abs(i+j)<>1)   ))
              then begin writeln('OTHER'); exit; end;
        end;

     writeln('CHECKMATE');
   {
     for i:=1 to 8 do
       begin
       for j:=1 to 8 do
         write(mas[i,j]);
       writeln;
      end;

   readln(i);  }
end.

program myw;

{$APPTYPE CONSOLE}

uses
  SysUtils;

  type Point = record
    x : longint;
    y : longint;
   end;

var i,j : longint;  s : char;
    a,b,c,d : point;
    mas : array[0..9,0..9] of longint;
begin
   read(s);
   a.x:=ord(s)-ord('a')+1;
   read(s);
   a.y:=ord(s)-ord('0');
   read(s);
   read(s);
   b.x:=ord(s)-ord('a')+1;
   read(s);
   b.y:=ord(s)-ord('0');
   read(s);
   read(s);
   c.x:=ord(s)-ord('a')+1;
   read(s);
   c.y:=ord(s)-ord('0');
   read(s);
   read(s);
   d.x:=ord(s)-ord('a')+1;
   read(s);
   d.y:=ord(s)-ord('0');
   for i:=1 to 8 do
    for j:=1 to 8 do
      mas[i,j]:=0;
   for i:=1 to 8 do
     begin
       inc(mas[i,a.y]);
       inc(mas[a.x,i]);
       inc(mas[i,b.y]);
       inc(mas[b.x,i]);
     end;
    mas[a.x,a.y]:=0;
    mas[b.x,b.y]:=0;
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          inc(mas[c.x+i,c.y+j]);
        end;
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)
             and (mas[d.x+i,d.y+j]=0) then begin writeln('OTHER'); exit; end;
        end;

     writeln('CHECKMATE');

end.

program myw;

{$APPTYPE CONSOLE}

uses
  SysUtils;

  type Point = record
    x : longint;
    y : longint;
   end;

var i,j : longint;  s : char;
    a,b,c,d : point;
    mas : array[0..9,0..9] of longint;
begin
   read(s);
   a.x:=ord(s)-ord('a')+1;
   read(s);
   a.y:=ord(s)-ord('0');
   read(s);
   read(s);
   b.x:=ord(s)-ord('a')+1;
   read(s);
   b.y:=ord(s)-ord('0');
   read(s);
   read(s);
   c.x:=ord(s)-ord('a')+1;
   read(s);
   c.y:=ord(s)-ord('0');
   read(s);
   read(s);
   d.x:=ord(s)-ord('a')+1;
   read(s);
   d.y:=ord(s)-ord('0');
   for i:=1 to 8 do
    for j:=1 to 8 do
      mas[i,j]:=0;
   for i:=1 to 8 do
     begin
       inc(mas[i,a.y]);
    //   if (i=d.x) and (a.y=d.y) then begin writeln('CHECKMATE'); exit; end;
       inc(mas[a.x,i]);
    //   if (a.x=d.x) and (i=d.y) then begin writeln('CHECKMATE'); exit; end;
       inc(mas[i,b.y]);
    //   if (i=d.x) and (a.y=b.y) then begin writeln('CHECKMATE'); exit; end;
       inc(mas[b.x,i]);
    //   if (b.x=d.x) and (i=d.y) then begin writeln('CHECKMATE'); exit; end;
     end;

    dec(mas[a.x,a.y],2);
    dec(mas[b.x,b.y],2);
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          inc(mas[c.x+i,c.y+j]);
        end;
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          if (i=0) and (j=0) then continue;
          if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)
             and (mas[d.x+i,d.y+j]=0)
              then begin writeln('OTHER'); exit; end;
        end;

     writeln('CHECKMATE');
   {
         for i:=1 to 8 do
       begin
       for j:=1 to 8 do
         write(mas[i,j]);
       writeln;
      end;

   readln(i);
    }
end.

program myw;

{$APPTYPE CONSOLE}

uses
  SysUtils;

  type Point = record
    x : longint;
    y : longint;
   end;

var i,j : longint;  s : char;
    a,b,c,d : point;
    mas : array[0..9,0..9] of longint;
begin
   read(s);
   a.x:=ord(s)-ord('a')+1;
   read(s);
   a.y:=ord(s)-ord('0');
   read(s);
   read(s);
   b.x:=ord(s)-ord('a')+1;
   read(s);
   b.y:=ord(s)-ord('0');
   read(s);
   read(s);
   c.x:=ord(s)-ord('a')+1;
   read(s);
   c.y:=ord(s)-ord('0');
   read(s);
   read(s);
   d.x:=ord(s)-ord('a')+1;
   read(s);
   d.y:=ord(s)-ord('0');
   for i:=1 to 8 do
    for j:=1 to 8 do
      mas[i,j]:=0;
   for i:=1 to 8 do
     begin
       inc(mas[i,a.y]);
    //   if (i=d.x) and (a.y=d.y) then begin writeln('CHECKMATE'); exit; end;
       inc(mas[a.x,i]);
    //   if (a.x=d.x) and (i=d.y) then begin writeln('CHECKMATE'); exit; end;
       inc(mas[i,b.y]);
    //   if (i=d.x) and (a.y=b.y) then begin writeln('CHECKMATE'); exit; end;
       inc(mas[b.x,i]);
    //   if (b.x=d.x) and (i=d.y) then begin writeln('CHECKMATE'); exit; end;
     end;

    dec(mas[a.x,a.y],2);
    dec(mas[b.x,b.y],2);
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
          inc(mas[c.x+i,c.y+j]);
        end;
    for i:=-1 to 1 do
      for j:=-1 to 1 do
        begin
       //   if (i=0) and (j=0) then continue;
          if (d.x+i>0) and (d.x+i<9) and (d.y+j>0) and (d.y+j<9)
             and (mas[d.x+i,d.y+j]=0)
              then begin writeln('OTHER'); exit; end;
        end;

     writeln('CHECKMATE');
   {
         for i:=1 to 8 do
       begin
       for j:=1 to 8 do
         write(mas[i,j]);
       writeln;
      end;

   readln(i);
        }
end.

type c=record
     x,y:byte;
     end;
var j,i,k:byte;
    s,l:string;
    m:array[0..9,0..9] of boolean;
    l1,l2,k1,k2:c;
begin
readln(l);
for i:=0 to 9 do
    for j:=0 to 9 do
    m[i,j]:=true;
for i:=1 to 8 do
    for j:=1 to 8 do
    m[i,j]:=false;
s:='abcdefgh';
l1.x:=pos(l[1],s);
l1.y:=ord(l[2])-48;
l2.x:=pos(l[4],s);
l2.y:=ord(l[5])-48;
k1.x:=pos(l[7],s);
k1.y:=ord(l[8])-48;
k2.x:=pos(l[10],s);
k2.y:=ord(l[11])-48;
for i:=1 to l1.x-1 do
    m[i,l1.y]:=true;
for i:=l1.x+1 to 9 do
    m[i,l1.y]:=true;
for i:=1 to l1.y-1 do
    m[l1.x,i]:=true;
for i:=l1.y+1 to 9 do
    m[l1.x,i]:=true;
for i:=1 to l2.x-1 do
    m[i,l2.y]:=true;
for i:=l2.x+1 to 9 do
    m[i,l2.y]:=true;
for i:=1 to l2.y-1 do
    m[l2.x,i]:=true;
for i:=l2.y+1 to 9 do
    m[l2.x,i]:=true;
for i:=k1.x-1 to k1.x+1 do
    for j:=k1.y-1 to k1.y+1 do
    m[i,j]:=true;
if (m[k2.x+1,k2.y+1]=true) and  (m[k2.x+1,k2.y]=true) and (m[k2.x+1,k2.y-1]=true) and (m[k2.x,k2.y+1]=true) and (m[k2.x,k2.y]=true) and (m[k2.x,k2.y-1]=true) and (m[k2.x-1,k2.y+1]=true) and (m[k2.x-1,k2.y]=true) and (m[k2.x-1,k2.y-1]=true) then
   s:='CHECKMATE'
   else s:='OTHER';
writeln(s);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var a:array[1..10,1..10]of Longint;
    s:String;
    x,y,x1,y1,x2,y2,x3,y3,i:Longint;

begin
  //Reset(Input,'in.txt');
  //Rewrite(Output,'out.txt');
  Read(s);
  FillChar(a,sizeof(a),0);
  for i:=1 to 10 do
    begin
      a[1,i]:=-1;
      a[i,10]:=-1;
      a[10,i]:=-1;
      a[i,1]:=-1;
    end;
  x:=ord(s[1])-48-47;
  y:=StrToInt(s[2])+1;
  Delete(s,1,3);
  a[x,y]:=1;
  x1:=ord(s[1])-48-47;
  y1:=StrToInt(s[2])+1;
  Delete(s,1,3);
  a[x1,y1]:=1;
  x2:=ord(s[1])-48-47;
  y2:=StrToInt(s[2])+1;
  Delete(s,1,3);
  a[x2,y2]:=2;
  x3:=ord(s[1])-48-47;
  y3:=StrToInt(s[2])+1;
  for i:=x+1 to 9 do
    if a[i,y]=2 then break else
    a[i,y]:=-1;
  for i:=x-1 downto 2 do
    if a[i,y]=2 then break else
    a[i,y]:=-1;
  for i:=y+1 to 9 do
    if a[x,i]=2 then break else
    a[x,i]:=-1;
  for i:=y-1 downto 2 do
    if a[x,i]=2 then break else
    a[x,i]:=-1;

  for i:=x1+1 to 9 do
    if a[i,y1]=2 then break else
    a[i,y1]:=-1;
  for i:=x1-1 downto 2 do
    if a[i,y1]=2 then break else
    a[i,y1]:=-1;
  for i:=y1+1 to 9 do
    if a[x1,i]=2 then break else
    a[x1,i]:=-1;
  for i:=y1-1 downto 2 do
    if a[x1,i]=2 then break else
    a[x1,i]:=-1;
  a[x3,y2]:=3;
  if (a[x3-1,y3]<>-1)or(a[x3+1,y3]<>-1)or
     (a[x3,y3-1]<>-1)or(a[x3,y3+1]<>-1)or
     (a[x3-1,y3-1]<>-1)or(a[x3-1,y3+1]<>-1)or
     (a[x3+1,y3-1]<>-1)or(a[x3+1,y3-1]<>-1)then
     Write('OTHER')else Write('CHECKMATE');
end.

program b41;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var d:array[0..9,0..9] of integer;
    fig:array[1..4,1..2] of integer;
    ch:array[1..8] of char=('a','b','c','d','e','f','g','h');
    i,j,k,t1,t2:integer;
    st:string;
    f:boolean;

begin
  // ������ ������, ������� ������� �����
  readln(st);
  st:=st+' ';
  for k:=1 to 4 do
    begin
      for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;
      fig[k,1]:=StrToInt(copy(st,2,1));
      delete(st,1,3);
    end;
  // "������" ������ �� �����, ��������� ����� �� ��������� 1-��
  d[fig[1,1],fig[1,2]]:=2;
  d[fig[2,1],fig[2,2]]:=2;
  d[fig[3,1],fig[3,2]]:=3;
  d[fig[4,1],fig[4,2]]:=4;
  for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;
  for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;
  // "���������" ������, �������������� 1-� ������
  i:=fig[1,1]-1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then i:=i-2 else i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then i:=i+2 else i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then j:=j-2 else j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then i:=j+2 else j:=j+1;
    end;
  // "���������" ������, �������������� 2-� ������
  i:=fig[2,1]-1; j:=fig[2,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then i:=i-2 else i:=i-1;
    end;
  i:=fig[2,1]+1; j:=fig[2,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then i:=i+2 else i:=i+1;
    end;
  i:=fig[2,1]; j:=fig[2,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then j:=j-2 else j:=j-1;
    end;
  i:=fig[2,1]; j:=fig[2,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then i:=j+2 else j:=j+1;
    end;
  // "���������" ������, �������������� ��������� �������
  i:=fig[3,1]; j:=fig[3,2];
  if d[i,j-1]=0 then d[i,j-1]:=1;
  if d[i,j-1]=2 then d[i,j-1]:=5;
  if d[i,j+1]=0 then d[i,j+1]:=1;
  if d[i,j+1]=2 then d[i,j+1]:=5;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if d[i-1,j]=0 then d[i-1,j]:=1;
    if d[i+1,j]=0 then d[i+1,j]:=1;
    if d[i-1,j]=2 then d[i-1,j]:=5;
    if d[i+1,j]=2 then d[i+1,j]:=5;
  end;
  // ��������� ����������� ����
  i:=fig[4,1]; j:=fig[4,2];
  f:=false;
  if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;
  if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;
    if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;
  end;
  if f then writeln('OTHER') else writeln('CHECKMATE');
  readln;
end.

program b41;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var d:array[0..9,0..9] of integer;
    fig:array[1..4,1..2] of integer;
    di:array[1..8] of byte=(8,7,6,5,4,3,2,1);
    ch:array[1..8] of char=('a','b','c','d','e','f','g','h');
    i,j,k,t1,t2:integer;
    st:string;
    s,f:boolean;

begin
  readln(st);
  st:=st+' ';
  for k:=1 to 4 do
    begin
      for i:=1 to 8 do begin
        if ch[i]=copy(st,1,1) then fig[k,2]:=i;
        if di[i]=StrToInt(copy(st,2,1)) then fig[k,1]:=i;
      end;
      delete(st,1,3);
    end;
  d[fig[1,1],fig[1,2]]:=2;
  d[fig[2,1],fig[2,2]]:=2;
  d[fig[3,1],fig[3,2]]:=3;
  d[fig[4,1],fig[4,2]]:=4;
  for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;
  for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;
  s:=false;
  i:=fig[1,1]-1; j:=fig[1,2];
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then begin s:=True; j:=j+2 end else j:=j+1;
    end;
  i:=fig[2,1]-1; j:=fig[2,2];
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;
    end;
  i:=fig[2,1]+1; j:=fig[2,2];
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;
    end;
  i:=fig[2,1]; j:=fig[2,2]-1;
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;
    end;
  i:=fig[2,1]; j:=fig[2,2]+1;
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then begin s:=True; j:=j+2 end else j:=j+1;
    end;
  i:=fig[3,1]; j:=fig[3,2];
  if d[i,j-1]=0 then d[i,j-1]:=1;
  if d[i,j-1]=2 then d[i,j-1]:=5;
  if d[i,j+1]=0 then d[i,j+1]:=1;
  if d[i,j+1]=2 then d[i,j+1]:=5;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if d[i-1,j]=0 then d[i-1,j]:=1;
    if d[i+1,j]=0 then d[i+1,j]:=1;
    if d[i-1,j]=2 then d[i-1,j]:=5;
    if d[i+1,j]=2 then d[i+1,j]:=5;
  end;
  i:=fig[4,1]; j:=fig[4,2];
  f:=false;
  if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;
  if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;
    if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;
  end;
  if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');
  readln;
end.

program b41;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var d:array[0..9,0..9] of integer;
    fig:array[1..4,1..2] of integer;
    ch:array[1..8] of char=('a','b','c','d','e','f','g','h');
    i,j,k,t1,t2:integer;
    st:string;
    s,f:boolean;

begin

  readln(st);
  st:=st+' ';
  for k:=1 to 4 do
    begin
      for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;
      fig[k,1]:=StrToInt(copy(st,2,1));
      delete(st,1,3);
    end;

  d[fig[1,1],fig[1,2]]:=2;
  d[fig[2,1],fig[2,2]]:=2;
  d[fig[3,1],fig[3,2]]:=3;
  d[fig[4,1],fig[4,2]]:=4;
  for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;
  for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;

  s:=false;
  i:=fig[1,1]-1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;
    end;

  i:=fig[2,1]-1; j:=fig[2,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;
    end;
  i:=fig[2,1]+1; j:=fig[2,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;
    end;
  i:=fig[2,1]; j:=fig[2,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;
    end;
  i:=fig[2,1]; j:=fig[2,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;
    end;

  i:=fig[3,1]; j:=fig[3,2];
  if d[i,j-1]=0 then d[i,j-1]:=1;
  if d[i,j-1]=2 then d[i,j-1]:=5;
  if d[i,j+1]=0 then d[i,j+1]:=1;
  if d[i,j+1]=2 then d[i,j+1]:=5;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if d[i-1,j]=0 then d[i-1,j]:=1;
    if d[i+1,j]=0 then d[i+1,j]:=1;
    if d[i-1,j]=2 then d[i-1,j]:=5;
    if d[i+1,j]=2 then d[i+1,j]:=5;
  end;

  i:=fig[4,1]; j:=fig[4,2];
  f:=false;
  if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;
  if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;
    if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;
  end;
  if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');
  readln;
end.

program b41;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var d:array[0..9,0..9] of integer;
    fig:array[1..4,1..2] of integer;
    ch:array[1..8] of char=('a','b','c','d','e','f','g','h');
    i,j,k,t1,t2:integer;
    st:string;
    f:boolean;

begin
  // ×èòàåì ñòðîêó, íàõîäèì èíäåêñû ôèãóð
  readln(st);
  st:=st+' ';
  for k:=1 to 4 do
    begin
      for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;
      fig[k,1]:=StrToInt(copy(st,2,1));
      delete(st,1,3);
    end;
  // "Ñòàâèì" ôèãóðû íà äîñêó, çàïîëíÿåì äîñêó ïî ïåðèìåòðó 1-ìè
  d[fig[1,1],fig[1,2]]:=2;
  d[fig[2,1],fig[2,2]]:=2;
  d[fig[3,1],fig[3,2]]:=3;
  d[fig[4,1],fig[4,2]]:=4;
  for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;
  for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;
  // "Çàêðûâàåì" êëåòêè, êîíòðîëèðóåìûå 1-é ëàäüåé
  i:=fig[1,1]-1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      j:=j+1;
    end;
  // "Çàêðûâàåì" êëåòêè, êîíòðîëèðóåìûå 2-é ëàäüåé
  i:=fig[2,1]-1; j:=fig[2,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      j:=j+1;
    end;
  // "Çàêðûâàåì" êëåòêè, êîíòðîëèðóåìûå âðàæåñêèì êîðîëåì
  i:=fig[3,1]; j:=fig[3,2];
  if d[i,j-1]=0 then d[i,j-1]:=1;
  if d[i,j-1]=2 then d[i,j-1]:=5;
  if d[i,j+1]=0 then d[i,j+1]:=1;
  if d[i,j+1]=2 then d[i,j+1]:=5;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if d[i-1,j]=0 then d[i-1,j]:=1;
    if d[i+1,j]=0 then d[i+1,j]:=1;
    if d[i-1,j]=2 then d[i-1,j]:=5;
    if d[i+1,j]=2 then d[i+1,j]:=5;
  end;
  // Ïðîâåðÿåì âîçìîæíîñòü õîäà
  i:=fig[4,1]; j:=fig[4,2];
  f:=false;
  if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;
  if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;
    if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;
  end;
  if f then writeln('OTHER') else writeln('CHECKMATE');
  readln;
end.

program b41;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var d:array[0..9,0..9] of integer;
    fig:array[1..4,1..2] of integer;
    ch:array[1..8] of char=('a','b','c','d','e','f','g','h');
    i,j,k,t1,t2:integer;
    st:string;
    f:boolean;

begin
  // ������ ������, ������� ������� �����
  readln(st);
  st:=st+' ';
  for k:=1 to 4 do
    begin
      for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;
      fig[k,1]:=StrToInt(copy(st,2,1));
      delete(st,1,3);
    end;
  // "������" ������ �� �����, ��������� ����� �� ��������� 1-��
  d[fig[1,1],fig[1,2]]:=2;
  d[fig[2,1],fig[2,2]]:=2;
  d[fig[3,1],fig[3,2]]:=3;
  d[fig[4,1],fig[4,2]]:=4;
  for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;
  for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;
  // "���������" ������, �������������� 1-� ������
  i:=fig[1,1]-1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then i:=i-2 else i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then i:=i+2 else i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then j:=j-2 else j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then i:=j+2 else j:=j+1;
    end;
  // "���������" ������, �������������� 2-� ������
  i:=fig[2,1]-1; j:=fig[2,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then i:=i-2 else i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then i:=i+2 else i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then j:=j-2 else j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then i:=j+2 else j:=j+1;
    end;
  // "���������" ������, �������������� ��������� �������
  i:=fig[3,1]; j:=fig[3,2];
  if d[i,j-1]=0 then d[i,j-1]:=1;
  if d[i,j-1]=2 then d[i,j-1]:=5;
  if d[i,j+1]=0 then d[i,j+1]:=1;
  if d[i,j+1]=2 then d[i,j+1]:=5;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if d[i-1,j]=0 then d[i-1,j]:=1;
    if d[i+1,j]=0 then d[i+1,j]:=1;
    if d[i-1,j]=2 then d[i-1,j]:=5;
    if d[i+1,j]=2 then d[i+1,j]:=5;
  end;
  // ��������� ����������� ����
  i:=fig[4,1]; j:=fig[4,2];
  f:=false;
  if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;
  if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;
    if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;
  end;
  if f then writeln('OTHER') else writeln('CHECKMATE');
  readln;
end.

program b41;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var d:array[0..9,0..9] of integer;
    fig:array[1..4,1..2] of integer;
    ch:array[1..8] of char=('h','g','f','e','d','c','b','a');
    i,j,k,t1,t2:integer;
    st:string;
    s,f:boolean;

begin
  readln(st);
  st:=st+' ';
  for k:=1 to 4 do
    begin
      for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[k,2]:=i;
      fig[k,1]:=StrToInt(copy(st,2,1));
      delete(st,1,3);
    end;
  d[fig[1,1],fig[1,2]]:=2;
  d[fig[2,1],fig[2,2]]:=2;
  d[fig[3,1],fig[3,2]]:=3;
  d[fig[4,1],fig[4,2]]:=4;
  for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;
  for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;
  s:=false;
  i:=fig[1,1]-1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;
    end;
  i:=fig[2,1]-1; j:=fig[2,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;
    end;
  i:=fig[2,1]+1; j:=fig[2,2];
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;
    end;
  i:=fig[2,1]; j:=fig[2,2]-1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;
    end;
  i:=fig[2,1]; j:=fig[2,2]+1;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;
    end;
  i:=fig[3,1]; j:=fig[3,2];
  if d[i,j-1]=0 then d[i,j-1]:=1;
  if d[i,j-1]=2 then d[i,j-1]:=5;
  if d[i,j+1]=0 then d[i,j+1]:=1;
  if d[i,j+1]=2 then d[i,j+1]:=5;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if d[i-1,j]=0 then d[i-1,j]:=1;
    if d[i+1,j]=0 then d[i+1,j]:=1;
    if d[i-1,j]=2 then d[i-1,j]:=5;
    if d[i+1,j]=2 then d[i+1,j]:=5;
  end;
  i:=fig[4,1]; j:=fig[4,2];
  f:=false;
  if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;
  if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;
    if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;
  end;
  if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');
  readln;
end.

program b41;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var d:array[0..9,0..9] of integer;
    fig:array[1..4,1..2] of integer;
    ch:array[1..8] of char=('a','b','c','d','e','f','g','h');
    i,j,l,i1,j1,k:integer;
    st:string;
    a:char;

begin
  readln(st);
  st:=st+' ';
  for l:=1 to 4 do
    begin
      for i:=1 to 8 do if ch[i]=copy(st,1,1) then fig[l,2]:=i;
      fig[l,1]:=StrToInt(copy(st,2,1));
      delete(st,1,3);
    end;
  d[fig[1,1],fig[1,2]]:=1;
  d[fig[2,1],fig[2,2]]:=1;
  d[fig[3,1],fig[3,2]]:=2;
  d[fig[4,1],fig[4,2]]:=5;
  for i:=1 to 8 do
    for j:=1 to 8 do begin
      if d[i,j]=1 then begin
        for i1:=1 to 8 do if d[i1,j]=0 then d[i1,j]:=3;
        for j1:=1 to 8 do if d[i,j1]=0 then d[i,j1]:=3;
      if d[i,j]=2 then begin
        if d[i-1,j-1]=0 then d[i-1,j-1]:=4;
        if d[i-1,j]=0 then d[i-1,j]:=4;
        if d[i-1,j+1]=0 then d[i-1,j+1]:=4;
        if d[i,j-1]=0 then d[i,j-1]:=4;
        if d[i,j+1]=0 then d[i,j+1]:=4;
        if d[i+1,j-1]=0 then d[i+1,j-1]:=4;
        if d[i+1,j]=0 then d[i+1,j]:=4;
        if d[i+1,j+1]=0 then d[i+1,j+1]:=4;
      end;
    end;
  end;
  k:=0;
  for i:=1 to 8 do
    for j:=1 to 8 do
      if d[i,j]=5 then begin
        if (d[i-1,j-1]=0) and (i<>1) and (j<>1) then k:=k+1;
        if (d[i-1,j]=0) and (i<>1) then k:=k+1;
        if (d[i-1,j+1]=0) and (i<>1) and (j<>8) then k:=k+1;
        if (d[i,j-1]=0) and (j<>1) then k:=k+1;
        if (d[i,j+1]=0) and (j<>8) then k:=k+1;
        if (d[i+1,j-1]=0) and (i<>8) and (j<>1) then k:=k+1;
        if (d[i+1,j]=0) and (i<>8) then k:=k+1;
        if (d[i+1,j+1]=0) and (i<>8) and (j<>8) then k:=k+1;
      end;
  if k>0 then writeln('OTHER') else writeln('CHECKMATE');
  readln;
end.

program b41;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var d:array[0..9,0..9] of integer;
    fig:array[1..4,1..2] of integer;
    di:array[1..8] of byte=(8,7,6,5,4,3,2,1);
    ch:array[1..8] of char=('a','b','c','d','e','f','g','h');
    i,j,k,t1,t2:integer;
    st:string;
    s,f:boolean;

begin
  readln(st);
  st:=st+' ';
  for k:=1 to 4 do
    begin
      for i:=1 to 8 do begin
        if ch[i]=copy(st,1,1) then fig[k,2]:=i;
        if di[i]=StrToInt(copy(st,2,1)) then fig[k,1]:=i;
      end;
      delete(st,1,3);
    end;
  d[fig[1,1],fig[1,2]]:=2;
  d[fig[2,1],fig[2,2]]:=2;
  d[fig[3,1],fig[3,2]]:=3;
  d[fig[4,1],fig[4,2]]:=4;
  for i:=0 to 9 do begin d[i,0]:=9; d[i,9]:=9 end;
  for j:=0 to 9 do begin d[0,j]:=9; d[9,j]:=9 end;
  s:=false;
  i:=fig[1,1]-1; j:=fig[1,2];
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;
    end;
  i:=fig[1,1]+1; j:=fig[1,2];
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;
    end;
  i:=fig[1,1]; j:=fig[1,2]-1;
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;
    end;
  i:=fig[1,1]; j:=fig[1,2]+1;
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then begin s:=True; i:=j+2 end else j:=j+1;
    end;
  i:=fig[2,1]-1; j:=fig[2,2];
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i-1,j]=2 then d[i-1,j]:=5;
      if d[i-1,j]=4 then begin s:=True; i:=i-2 end else i:=i-1;
    end;
  i:=fig[2,1]+1; j:=fig[2,2];
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i+1,j]=2 then d[i+1,j]:=5;
      if d[i+1,j]=4 then begin s:=True; i:=i+2 end else i:=i+1;
    end;
  i:=fig[2,1]; j:=fig[2,2]-1;
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j-1]=2 then d[i,j-1]:=5;
      if d[i,j-1]=4 then begin s:=True; j:=j-2 end else j:=j-1;
    end;
  i:=fig[2,1]; j:=fig[2,2]+1;
  if d[i,j]=2 then d[i,j]:=5;
  while (d[i,j]=0) or (d[i,j]=1) do
    begin
      d[i,j]:=1;
      if d[i,j+1]=2 then d[i,j+1]:=5;
      if d[i,j+1]=4 then begin s:=True; j:=j+2 end else j:=j+1;
    end;
  i:=fig[3,1]; j:=fig[3,2];
  if d[i,j-1]=0 then d[i,j-1]:=1;
  if d[i,j-1]=2 then d[i,j-1]:=5;
  if d[i,j+1]=0 then d[i,j+1]:=1;
  if d[i,j+1]=2 then d[i,j+1]:=5;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if d[i-1,j]=0 then d[i-1,j]:=1;
    if d[i+1,j]=0 then d[i+1,j]:=1;
    if d[i-1,j]=2 then d[i-1,j]:=5;
    if d[i+1,j]=2 then d[i+1,j]:=5;
  end;
  i:=fig[4,1]; j:=fig[4,2];
  f:=false;
  if (d[i,j-1]=0) or (d[i,j-1]=2) then f:=f or True;
  if (d[i,j+1]=0) or (d[i,j+1]=2) then f:=f or True;
  t1:=j-1; t2:=j+1;
  for j:=t1 to t2 do begin
    if (d[i-1,j]=0) or (d[i-1,j]=2) then f:=f or True;
    if (d[i+1,j]=0) or (d[i+1,j]=2) then f:=f or True;
  end;
  if (f=s) or (f and not(s)) then writeln('OTHER') else writeln('CHECKMATE');
  readln;
end.

program Project1;
{$APPTYPE CONSOLE}
{$R+}
uses
SysUtils;
var
e,w,i,j,x1,x2,x3,x4,y1,y2,y3,y4,y,x:longint;
z:boolean;
s:string;
procedure svoboda;
begin
  write('OTHER');
  halt(0);
end;
begin
//reset(input,'input.txt');rewrite(output,'output.txt');
read(s);
x1:=ord(s[1])-96;
y1:=strtoint(s[2]);
x2:=ord(s[4])-96;
y2:=strtoint(s[5]);
x3:=ord(s[7])-96;
y3:=strtoint(s[8]);
x:=ord(s[10])-96;
y:=strtoint(s[11]);

if x1<>x then
if x2<>x then
if y1<>y then
if y2<>y then svoboda;

for i:=y-1 to y+1 do
for j:=x-1 to x+1 do
if i>0 then
if i<9 then
if j>0 then
if j<9 then
begin
z:=true;
for w:=i-1 to i+1 do
for e:=j-1 to j+1 do
if w=y3 then
if e=x3 then z:=false;
if(i=y1)or(j=x1)then
if i+j<>x1+y1 then  z:=false;
if(i=y2)or(j=x2)then
if i+j<>x2+y2 then  z:=false;
if z then svoboda;
end;

write('CHECKMATE');
end.

program pjb;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  iCnt,iRook1Y,iRook2Y,iKing1Y,iKing2Y: integer;
  cCnt,cRook1X,cRook2X,cKing1X,cKing2X: char;
  sTemp: string;
  bCheckmate: boolean;
  baArea: array ['a'..'z',0..9] of boolean;

function Ic(c1: char; i1: integer): char;
var
  cREsult: char;
begin
  case i1 of
    1:
    begin
      case c1 of
        'a': cResult := 'b';
        'b': cResult := 'c';
        'c': cResult := 'd';
        'd': cResult := 'e';
        'e': cResult := 'f';
        'f': cResult := 'g';
        'g': cResult := 'h';
        'h': cResult := 'h';
        end;
      end;
    -1:
    begin
      case c1 of
        'a': cResult := 'a';
        'b': cResult := 'a';
        'c': cResult := 'b';
        'd': cResult := 'c';
        'e': cResult := 'd';
        'f': cResult := 'e';
        'g': cResult := 'f';
        'h': cResult := 'g';
        end;
      end;
    end;
  Ic := cResult;
end;

begin
  Readln(sTemp);
  cRook1X := sTemp[1];
  iRook1Y := Strtoint(sTemp[2]);
  cRook2X := sTemp[4];
  iRook2Y := Strtoint(sTemp[5]);
  cKing1X := sTemp[7];
  iKing1Y := Strtoint(sTEmp[8]);
  cKIng2X := sTEmp[10];
  iKing2Y := Strtoint(sTEmp[11]);
  for cCnt := 'a' to 'z' do baArea[cCnt,0] := true;
  for cCnt := 'a' to 'z' do baArea[cCnt,9] := true;

  for iCnt := 1 to 8 do if (iCnt <> iRook1Y) then baArea[cRook1X,iCnt] := true;
  for iCnt := 1 to 8 do if (iCnt <> iRook2Y) then baArea[cRook2X,iCnt] := true;
  for cCnt := 'a' to 'z' do if (cCnt <> cRook1X) then baArea[cCnt,iRook1Y] := true;
  for cCnt := 'a' to 'z' do if (cCnt <> cRook2X) then baArea[cCnt,iRook2Y] := true;
  baArea[Ic(cKing1X,-1),iKing1Y] := true;
  baArea[Ic(cKing1X,1),iKing1Y] := true;
  baArea[cKing1X,iKing1Y - 1] := true;
  baArea[cKing1X,iKing1Y + 1] := true;
  baArea[Ic(cKing1X,-1),iKing1Y - 1] := true;
  baArea[Ic(cKing1X,-1),iKing1Y + 1] := true;
  baArea[Ic(cKing1X,1),iKing1Y - 1] := true;
  baArea[Ic(cKing1X,1),iKing1Y + 1] := true;

  bCheckmate := true;
  if (baArea[Ic(cKing2X,-1),iKing2Y] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,1),iKing2Y] = false)
    then bCheckmate := false;
  if (baArea[cKing2X,iKing2Y - 1] = false)
    then bCheckmate := false;
  if (baArea[cKing2X,iKing2Y + 1] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,-1),iKing2Y - 1] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,-1),iKing2Y + 1] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,1),iKing2Y - 1] = false)
    then bCheckmate := false;
  if (baArea[Ic(cKing2X,1),iKing2Y + 1] = false)
    then bCheckmate := false;
  if (baArea[cKing2X,iKing2Y] = false)
    then bCheckmate := false;

  if (bCheckmate = true)
    then Writeln('CHECKMATE')
    else Writeln('OTHER');
end.