1376: 马走日

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:3 Solved:2

Description

给两个数n,m表示棋盘的大小
给一个坐标(x,y)表示马的位置,给一个目标目标(ex,ey)表示目标位置
输出马到目标位置所需要移动的最小次数,若不能到达,输出-1
马移动的规则同象棋,且马不能移出棋盘外




Input

第一行两个整数n,m
第二行4个正整数表示,两对坐标(x,y),(ex,ey)


Output

输出最小移动次数

Sample Input Copy

3 3
1 1 3 1

Sample Output Copy

2

HINT

$n,m\leq 1000 $
$x,ex\leq n$
$y,ey\leq m$

Source/Category