H,W=map(int,input().split()) A,B=map(int,input().split()) R1,C1,R2,C2=map(int,input().split()) P,Q=map(int,input().split()) T1=0 T2=0 ANS=0 if A