# Task
 An `amazon` (also known as a queen+knight compound) is an imaginary chess piece that can move like a `queen` or a `knight` (or, equivalently, like a `rook`, `bishop`, or `knight`). The diagram below shows all squares which the amazon attacks from e4 (circles represent knight-like moves while crosses correspond to queen-like moves).

 ![](https://codefightsuserpics.s3.amazonaws.com/tasks/amazonCheckmate/img/amazon.png?_tm=1473934566013)

 Recently you've come across a diagram with only three pieces left on the board: a `white amazon`, `white king` and `black king`. 
 
 It's black's move. You don't have time to determine whether the game is over or not, but you'd like to figure it out in your head. 
 
 Unfortunately, the diagram is smudged and you can't see the position of the `black king`, so it looks like you'll have to check them all.

 Given the positions of white pieces on a standard chessboard, determine the number of possible black king's positions such that: 

* It's a checkmate (i.e. black's king is under amazon's 
 attack and it cannot make a valid move);

* It's a check (i.e. black's king is under amazon's attack 
 but it can reach a safe square in one move);

* It's a stalemate (i.e. black's king is on a safe square 
 but it cannot make a valid move);

* Black's king is on a safe square and it can make a valid move.

Note that two kings cannot be placed on two adjacent squares (including two diagonally adjacent ones).

# Example

 For `king = "d3" and amazon = "e4"`, the output should be `[5, 21, 0, 29]`.

 ![](https://codefightsuserpics.s3.amazonaws.com/tasks/amazonCheckmate/img/example1.png?_tm=1473934566299)

 `Red crosses` correspond to the `checkmate` positions, `orange pluses` refer to `checks` and `green circles` denote `safe squares`.

 For `king = "a1" and amazon = "g5"`, the output should be `[0, 29, 1, 29]`.

 ![](https://codefightsuserpics.s3.amazonaws.com/tasks/amazonCheckmate/img/example2.png?_tm=1473934566670)

 `Stalemate` position is marked by a `blue square`.

# Input


 - String `king`

Position of white's king in chess notation.


 - String `amazon`

Position of white's amazon in the same notation.

Constraints: `amazon ≠ king.`

# Output

An array of four integers, each equal to the number of black's king positions corresponding to a specific situation. The integers should be presented in the same order as the situations were described, `i.e. 0 for checkmates, 1 for checks, etc`.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'd = {\'a\': 0, \'b\': 1, \'c\': 2, \'d\': 3, \'e\': 4, \'f\': 5, \'g\': 6, \'h\': 7}\nimport numpy as np\n\n# for x,i in for range(7)\n# iam the king, what is my situation\n# en rango 1 K, es king zone\n\ndef get_area(board,x,y):\n  return board[x-1 if x-1 >= 0 else 0 : x+2 if x+2<= 8 else 8 , y-1 if y-1 >= 0 else 0 : y+2 if y+2<= 8 else 8]\n\ndef get_neig(board,x,y):\n  rtrn = []\n  if x-1>=0:\n    if y-1 >= 0: rtrn.append(board[x-1,y-1])\n    rtrn.append(board[x-1,y])\n    if y+1 <8 : rtrn.append(board[x-1,y+1])\n  if y -1 >= 0: rtrn.append(board[x,y-1])\n  if y +1 < 8 : rtrn.append(board[x,y+1])\n  if x+1 <8:\n    if y-1 >= 0: rtrn.append(board[x+1,y-1])\n    rtrn.append(board[x+1,y])\n    if y+1 <8 : rtrn.append(board[x+1,y+1])\n    \n  return rtrn\n#   area=board[x-1 if x-1 >= 0 else 0 : x+2 if x+2<= 8 else 8 , y-1 if y-1 >= 0 else 0 : y+2 if y+2<= 8 else 8]\n        \n\ndef amazon_check_mate(king, amazon):\n    print(king,amazon)\n    board = np.array([[\'O\']*8 for i in range (8)])\n    kingx, kingy = int(king[1])-1, d[king[0]]\n    amazonx, amazony = int(amazon[1])-1, d[amazon[0]]\n    board[kingx][kingy]= \'K\'\n    board[amazonx][amazony] = \'A\'\n    \n    # King y alrededores\n    subarray = get_area(board,kingx,kingy)\n    for (x,y) in np.ndenumerate(subarray):\n        if y == \'O\':\n          subarray[x] = "N" # kingzone - Non posible  (numpy slices are views of the \'parent\' matrix, so it will modify board[[]])\n        if y == \'A\':\n          subarray[x] = \'F\' # Defended, fortified Amazon\n    \n    #Amazon y alrededores (the king breaks!!)\n    \n#     for xy in range(amazonx,len(board[0])):\n    for xy in range(amazony,8):\n      if board[amazonx, xy] == \'K\': break\n      elif board[amazonx, xy] == \'O\':\n        board[amazonx, xy] = \'W\'\n    for xy in range(amazony,-1,-1):\n      if board[amazonx, xy] == \'K\': break\n      elif board[amazonx, xy] == \'O\':\n        board[amazonx, xy] = \'W\'\n\n    for yx in range(amazonx,8):\n      if board[yx,amazony] == \'K\': break\n      elif board[yx,amazony] == \'O\':\n        board[yx,amazony] = \'W\'\n    for yx in range(amazonx,-1,-1):\n      if board[yx,amazony] == \'K\': break\n      elif board[yx,amazony] == \'O\':\n        board[yx,amazony] = \'W\'\n    \n    diag = np.diagonal(board,amazony-amazonx) #,amazony,amazonx)\n    diag.setflags(write=True)\n    if \'A\' in diag:\n      for di in range(np.where(diag==\'A\')[0][0] ,len(diag)):\n        if diag[di] == \'K\': break\n        if diag[di] == \'O\':\n          diag[di] =\'W\'   # In new numpy diag is also a view, so we are modifing board.\n      for di in range(np.where(diag==\'A\')[0][0] ,-1,-1):\n        if diag[di] == \'K\': break\n        if diag[di] == \'O\':\n          diag[di] =\'W\'   # In new numpy diag is also a view, so we are modifing board.\n    if \'F\' in diag:\n      for di in range(np.where(diag==\'F\')[0][0] ,len(diag)):\n        if diag[di] == \'K\': break\n        if diag[di] == \'O\':\n          diag[di] =\'W\'   # In new numpy diag is also a view, so we are modifing board.\n      for di in range(np.where(diag==\'F\')[0][0] ,-1,-1):\n        if diag[di] == \'K\': break\n        if diag[di] == \'O\':\n          diag[di] =\'W\'   # In new numpy diag is also a view, so we are modifing board.\n        \n    diag2 = np.rot90(board).diagonal(-8+amazonx+amazony+1) #,amazony,amazonx)\n    diag2.setflags(write=True)\n    if \'A\' in diag2:\n      for di in range(np.where(diag2==\'A\')[0][0] ,len(diag2)):\n        if diag2[di] == \'K\': break\n        if diag2[di] == \'O\':\n          diag2[di] =\'W\'   # In new numpy diag is also a view, so we are modifing board.\n      for di in range(np.where(diag2==\'A\')[0][0] ,-1,-1):\n        if diag2[di] == \'K\': break\n        if diag2[di] == \'O\':\n          diag2[di] =\'W\'   # In new numpy diag is also a view, so we are modifing board.\n    if \'F\' in diag:\n      for di in range(np.where(diag2==\'F\')[0][0] ,len(diag2)):\n        if diag2[di] == \'K\': break\n        if diag2[di] == \'O\':\n          diag2[di] =\'W\'   # In new numpy diag is also a view, so we are modifing board.\n      for di in range(np.where(diag2==\'F\')[0][0] ,-1,-1):\n        if diag2[di] == \'K\': break\n        if diag2[di] == \'O\':\n          diag2[di] =\'W\'   # In new numpy diag is also a view, so we are modifing board.\n    \n    #like a horse\n    if amazonx - 2 >= 0:\n      if amazony-1 >= 0 and board[amazonx-2,amazony-1] == \'O\': board[amazonx-2,amazony-1] = \'W\'\n      if amazony+1 < 8 and board[amazonx-2,amazony+1] == \'O\': board[amazonx-2,amazony+1] = \'W\'\n    if amazonx+2 < 8:\n      if amazony-1 >= 0 and board[amazonx+2,amazony-1] == \'O\': board[amazonx+2,amazony-1] = \'W\'\n      if amazony+1 < 8 and board[amazonx+2,amazony+1] == \'O\': board[amazonx+2,amazony+1] = \'W\'\n    if amazony -2 >= 0:\n      if amazonx-1 >= 0 and board[amazonx-1,amazony-2] == \'O\': board[amazonx-1,amazony-2] = \'W\'\n      if amazonx+1 < 8 and board[amazonx+1,amazony-2] == \'O\': board[amazonx+1,amazony-2] = \'W\'\n    if amazony +2 < 8:\n      if amazonx-1 >= 0 and board[amazonx-1,amazony+2] == \'O\': board[amazonx-1,amazony+2] = \'W\'\n      if amazonx+1 < 8 and board[amazonx+1,amazony+2] == \'O\': board[amazonx+1,amazony+2] = \'W\'\n\n    \n    # traverse\n#     if is O and no O arround, is stalemate. = S\n#     if is W and no O or A arround is checkmate = C\n    for i in range(8):\n      for j in range(8):\n        neigs = get_neig(board,i,j)\n        if board[i,j] == \'O\' and neigs.count(\'O\')==0:\n          board[i,j] = \'S\'\n        if board[i,j] == \'W\' and neigs.count(\'O\')+neigs.count(\'A\')+neigs.count(\'S\')==0:\n          board[i,j] = \'C\'\n   \n\n    checkmate,warning,stalemate,safe = 0,0,0,0\n    for p in np.nditer(board):\n      if p == \'C\':\n        checkmate+=1\n      elif p == \'W\':\n        warning+=1\n      elif p == \'S\':\n        stalemate +=1\n      elif p == \'O\':\n        safe+=1\n    return [checkmate,warning,stalemate,safe]'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'amazon_check_mate'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 16660