Little Petya is learning to play chess. He has already learned how to move a king, a rook and a bishop. Let us remind you the rules of moving chess pieces. A chessboard is 64 square fields organized into an 8 × 8 table. A field is represented by a pair of integers (r, c) — the number of the row and the number of the column (in a classical game the columns are traditionally indexed by letters). Each chess piece takes up exactly one field. To make a move is to move a chess piece, the pieces move by the following rules:  A rook moves any number of fields horizontally or vertically.  A bishop moves any number of fields diagonally.  A king moves one field in any direction — horizontally, vertically or diagonally.  [Image] The pieces move like that 

Petya is thinking about the following problem: what minimum number of moves is needed for each of these pieces to move from field (r_1, c_1) to field (r_2, c_2)? At that, we assume that there are no more pieces besides this one on the board. Help him solve this problem.


-----Input-----

The input contains four integers r_1, c_1, r_2, c_2 (1 ≤ r_1, c_1, r_2, c_2 ≤ 8) — the coordinates of the starting and the final field. The starting field doesn't coincide with the final one.

You can assume that the chessboard rows are numbered from top to bottom 1 through 8, and the columns are numbered from left to right 1 through 8.


-----Output-----

Print three space-separated integers: the minimum number of moves the rook, the bishop and the king (in this order) is needed to move from field (r_1, c_1) to field (r_2, c_2). If a piece cannot make such a move, print a 0 instead of the corresponding number.


-----Examples-----
Input
4 3 1 6

Output
2 1 3

Input
5 5 5 6

Output
1 0 1

Difficulty: interview

Starter code:

Solutions:
import math

x1, y1, x2, y2 = map(int, input().split())
if (x1 == x2) and (y1 == y2):
    print(0, 0, 0)
else:    
    # ladya
    if (x1 == x2) or (y1 == y2):
        l = 1
    else:
        l = 2
    
    #slon
    if (abs(x1 - x2) == abs(y1 - y2)):
        s = 1
    elif ((x1 + y1) % 2 == (x2 + y2) % 2): 
        s = 2
    else:
        s = 0

    #korol
    k = max(abs(x1 - x2), abs(y1 - y2))
    print(l, s, k)

r1,c1,r2,c2=map(int,input().split())

#Rook

if(r2!=r1 and c1!=c2):
    print(2,end=" ")
else:
    print(1,end=" ")


#Bishop

MoveInOne=False

for inx in [-1,1]:
    for iny in [-1,1]:
        x=r1
        y=c1
        while(x>0 and y>0 and x<=8 and y<=8):
            if(x==r2 and y==c2):
                MoveInOne=True
                break
            x+=inx
            y+=iny
if((r1+c1)%2!=(r2+c2)%2):
    print(0,end=" ")
elif(MoveInOne):
    print(1,end=" ")
else:
    print(2,end=" ")

x=abs(r2-r1)
y=abs(c2-c1)

print(max(x,y))


    


def rook(r1,c1,r2,c2):
	if r1==r2 or c1==c2:
		return 1
	else:
		return 2

def king(r1,c1,r2,c2):
	x = abs( c1-c2 )
	y = abs( r1-r2 )
	return max( x,y )


def bishop(r1,c1,r2,c2):
	if not (r1+c1)%2==(r2+c2)%2:
		return 0
	
	x = abs(r1-r2)
	y = abs(c1-c2)
	if x==y:
		return 1
	
	return 2
	

def __starting_point():
	r1,c1,r2,c2 = [int(x) for x in input().split()]
	r = rook(r1,c1,r2,c2)
	b = bishop(r1,c1,r2,c2)
	k = king(r1,c1,r2,c2)
	print( str(r)+' '+str(b)+' '+str(k) )
	

__starting_point()

3

def readln(): return tuple(map(int, input().split()))

r1, c1, r2, c2 = readln()
ans = [0, 0, 0]
if r1 == r2 or c1 == c2:
    ans[0] = 1
else:
    ans[0] = 2
if abs(r1 - r2) == abs(c1 - c2):
    ans[1] = 1
elif (abs(r1 - r2) % 2 == 0) == (abs(c1 - c2) % 2 == 0):
    ans[1] = 2
ans[2] = max(abs(r1 - r2), abs(c1 - c2))
print(*ans)


(r1,c1,r2,c2) = input().split()
r1 = int(r1)
c1 = int(c1)
r2 = int(r2)
c2 = int(c2)
s = ''
if r1 == r2 or c1 == c2:
    s += '1'
else:
    s += '2'
a = r1 + c1
b = r2 + c2
if (a + b)%2 == 1:
    s += ' 0 '
elif abs(r2-r1) == abs(c2-c1):
    s += ' 1 '
else:
    s += ' 2 '
a = abs(r1-r2)
b = abs(c1-c2)
c =max(a,b)
s += str(c)
print (s)
    


def stessocolore(x1,y1,x2,y2):
    if (x1+y1)%2 == (x2+y2)%2:
        return True
    else:
        return False
x1, y1, x2, y2 = map(int, input().split())
if x1 == x2 or y1 == y2:
    rook = 1
else:
    rook = 2
king = max([abs(x1-x2),abs(y1-y2)])
if stessocolore(x1,y1,x2,y2):
    if (x1-y1) == (x2-y2) or x1+y1 == x2+y2:
        bish = 1
    else:
        bish = 2
else:
    bish = 0

print(rook, bish, king)

# -*- coding: utf-8 -*-
from collections import deque

r1,c1,r2,c2 = map(int, input().split())
if r1 == r2 or c1 == c2:
    n1 = 1
else:
    n1 = 2
   
if (r1+c1)%2 != (r2+c2)%2:
    n2 = 0
elif r1+c1==r2+c2 or r1-c1==r2-c2:
    n2 = 1
else:
    n2 = 2
   
r_min, r_max, c_min, c_max = min(r1, r2), max(r1, r2), min(c1, c2), max(c1, c2)
chess = [[0]*9 for i in range(9)]
q = deque([(r1,c1)])
n3 = 0
while q:
    q2 = deque()
    while q:
        (r, c) = q.popleft()
        if (r, c) == (r2, c2):
            break
        chess[r][c] = 1
        if r-1 >= r_min and c-1 >= c_min and not chess[r-1][c-1]:
            q2.append((r-1, c-1))
        if r-1 >= r_min and not chess[r-1][c]:
            q2.append((r-1, c))
        if r-1 >= r_min and c+1 <= c_max and not chess[r-1][c+1]:
            q2.append((r-1, c+1))
        if c-1 >= c_min and not chess[r][c-1]:
            q2.append((r, c-1))
        if c+1 <= c_max and not chess[r][c+1]:
            q2.append((r, c+1))
        if r+1 <= r_max and c-1 >= c_min and not chess[r+1][c-1]:
            q2.append((r+1, c-1))
        if r+1 <= r_max and not chess[r+1][c]:
            q2.append((r+1, c))
        if r+1 <= r_max and c+1 <= c_max and not chess[r+1][c+1]:
            q2.append((r+1, c+1))
    else:
        q = q2
        n3 += 1
        continue
    break
    
print(n1, n2, n3)

# -*- coding: utf-8 -*-

r1,c1,r2,c2 = list(map(int, input().split()))
if r1 == r2 or c1 == c2:
    n1 = 1
else:
    n1 = 2
    
if (r1+c1)%2 != (r2+c2)%2:
    n2 = 0
elif r1+c1==r2+c2 or r1-c1==r2-c2:
    n2 = 1
else:
    n2 = 2

print(n1, n2, max(abs(r1-r2), abs(c1-c2)))


r1, c1, r2, c2 = map(int, input().split())

def rookMoves():
  return 1 if r1 == r2 or c1 == c2 else 2
def bishopMoves():
  if (r1 + c1) % 2 != (r2 + c2) % 2:
    return 0
  if r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2:
    return 1
  return 2
def kingMoves():
  return max(abs(r1 - r2), abs(c1 - c2))

print(rookMoves(), bishopMoves(), kingMoves())

__author__ = 'widoc'

r1, c1, r2, c2 = list(map(int, input().split()))

a1 = 1 if r1 == r2 or c1 == c2 else 2
a2 = 0
if abs(r1-r2) == abs(c1-c2):
    a2 = 1
elif (abs(r1-r2) + abs(c1-c2)) % 2 == 0:
    a2 = 2
a3 = max(abs(r1-r2),abs(c1-c2))

print(a1, a2, a3)



from math import fabs
a=[int(i)for i in input().split()]
if(a[0]==a[2])|(a[1]==a[3]):print(1,end=' ')
else:print(2,end=' ')
b,c=fabs(a[2]-a[0]),fabs(a[3]-a[1])
if b%2!=c%2:print(0,end=' ')
elif b==c:print(1,end=' ')
else:print(2,end=' ')
print(int(max(fabs(a[2]-a[0]),fabs(a[3]-a[1]))))

def main():
    r1, c1, r2, c2 = list(map(int, input().split()))
    _1, _2, _3 = 2, 2, 0
   
    if r1 == r2 or c1 == c2:
        _1 = 1
    
    if (r1+c1) % 2 != (r2+c2) % 2:
        _2 = 0
    elif r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2:
        _2 = 1

    _3 = max(abs(r1-r2), abs(c1-c2))
    print(_1, _2, _3)


def __starting_point():
    main()


__starting_point()

a,b,c,d=list(map(int,input().split()))
a = abs(a-c)
b = abs(b-d)

x = min(a, 1)+min(b, 1)
y = max(a, b)
z = 2
if a==b:
    z=1
if a+b==0 or (a+b)%2:
    z=0

print(x, z, y)


import sys
import math

r1, c1, r2, c2 = [int(x) for x in (sys.stdin.readline()).split()]

res = []
if(r1 == r2 and c1 == c2):
    print("0 0 0")
    return

if(r1 == r2 or c1 == c2):
    res.append("1")
else:
    res.append("2")

f1 = ((r1 + c1) % 2 == 0)
f2 = ((r2 + c2) % 2 == 0)

if(f1 != f2):
    res.append("0")
elif(math.fabs(r1 - r2) == math.fabs(c1 - c2)):
    res.append("1")
else:
    res.append("2")

res.append(str(int(max(math.fabs(r1 - r2), math.fabs(c1 - c2)))))

print(" ".join(res))

import math
x1,y1,x2,y2 = tuple(int(i) for i in input().split())
V = [[0 for j in range(10)] for i in range(10)]

def black(x,y):
	if(x%2==1):
		return y%2==1
	else:
		return y%2==0
a = 2
b = 0
c = 0

if(x1==x2):
	a-=1
if(y1==y2):
	a-=1

if(abs(x1-x2)==abs(y1-y2)):
	b=1
elif black(x1,y1)==black(x2,y2):
	b=2
else:
	b=0

c = max(abs(x1-x2),abs(y1-y2))
print(a,b,c)


def rook(r1,c1,r2,c2):
    if r1==r2 or c1==c2:
        return 1
    else:
        return 2

def bishop(r1,c1,r2,c2):
    s1 = r1+c1
    s2 = r2+c2
    if (s1%2==0 and s2%2!=0) or (s1%2!=0 and s2%2==0):
        return 0
    elif abs(r1-r2)==abs(c1-c2):
        return 1
    else:
        return 2

def king(r1,c1,r2,c2):
    mine = abs(r1-r2)+abs(c1-c2)
    #move horizonatal
    for i in range(1,9):
        if abs(i-r2)==abs(c1-c2):
            mine = min(mine,abs(i-r1)+abs(c1-c2))
    for i in range(1,9):
        if abs(i-c2)==abs(r1-r2):
            mine = min(mine,abs(i-c1)+abs(r2-r1))
    return mine

s = input().split()
r1 = int(s[0])
c1 = int(s[1])
r2 = int(s[2])
c2 = int(s[3])
ans = str(rook(r1,c1,r2,c2))+" "+str(bishop(r1,c1,r2,c2))+" "+str(king(r1,c1,r2,c2))
print(ans)



def foo():
   inp = input()
   r1, c1, r2, c2 = map(int, inp.split())
   if (r1 == r2 or c1 == c2):
      print("1", end = " ")
   else:
      print("2", end = " ")

   if ((r1 + c1) % 2) != ((r2 + c2) % 2):
      print("0", end = " ")
   elif (r1 - c1 == r2 - c2 or r1 + c1 == r2 + c2):
      print("1", end = " ")
   else:
      print("2", end = " ")

   print(max(abs(r1 - r2), abs(c1 - c2)))

foo()

import math
r1, c1, r2, c2 = input().split()
r1 = int(r1)
c1 = int(c1)
r2 = int(r2)
c2 = int(c2)
l = []
if math.fabs(r1 - r2) == 0 or math.fabs(c1 - c2) == 0:
    l.append(1)
else:
    l.append(2)
if math.fabs(r1 - r2) == math.fabs(c1 - c2):
    l.append(1)
elif (r1 + c1) % 2 == (r2 + c2) % 2:
    l.append(2)
else:
    l.append(0)
l.append(int(max(math.fabs(r1 - r2), math.fabs(c1 - c2))))

for i in l:
    print(i, end=" ")

def sign(num):
	return -1 if num < 0 else 1

def rook(cord):
	if cord[0] == cord[2] and cord[1] == cord[3]:
		return 0
	if cord[0] == cord[2] or cord[1] == cord[3]:
		return 1
	return 2 

def bishop(cord):
	if (cord[0] + cord[1]) % 2 != (cord[2] + cord[3]) % 2:
		return 0
	elif (cord[0] - cord[1] == cord[2] - cord[3]) or (cord[0] + cord[1] == cord[2] + cord[3]):
		return 1
	return 2

def king(cord):
	return max(abs(cord[0] - cord[2]), abs(cord[1] - cord[3]))

cord = list(map(int, input().split()))
print(rook(cord), bishop(cord), king(cord))


read = lambda: list(map(int, input().split()))
r1, c1, r2, c2 = read()
L = 1 if r1 == r2 or c1 == c2 else 2
K = max(abs(r1 - r2), abs(c1 - c2))
if abs(r1 - r2) == abs(c1 - c2): S = 1
elif (r1 + c1) % 2 == (r2 + c2) % 2: S = 2
else: S = 0
print(L, S, K)


a = input().split()

x1 = int(a[0])
y1 = int(a[1])
x2 = int(a[2])
y2 = int(a[3])

rook = 0
bishop = 0
king = 0

#rook
if (y1==y2) ^ (x1==x2):
    rook=1
elif y1==y2 and x1==x2:
    rook=0
else: rook=2

#bishop
if (x1==x2 and y1==y2) or ((abs(x1-x2))%2 != (abs(y1-y2))%2):
    bishop = 0
elif abs(x1-x2) == abs(y1-y2):
    bishop = 1
else: bishop = 2

#king
while x1!=x2 and y1!=y2:
    if x1<x2:
        x1+=1
    elif x1>x2:
        x1-=1
    if y1<y2:
        y1+=1
    elif y1>y2:
        y2+=1
    king+=1
while x1!=x2:
    if x1<x2:
        x1+=1
    elif x1>x2:
        x1-=1
    king+=1
while y1!=y2:
    if y1<y2:
        y1+=1
    elif y1>y2:
        y2+=1
    king+=1

print(rook,bishop,king)