from collections import deque 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()) if R1<=A<=R2 and C1<=B<=C2: k = 0 g = abs(A-P) + abs(B-Q) else: Dirc = [[-1,0], [1, 0], [0,-1], [0,1]] V = [[0 for _ in range(W)] for _ in range(H)] dq = deque() Flag = False dq.append([A-1, B-1, 0]) V[A-1][B-1] = 1 while(dq): a = dq.popleft() for d in Dirc: x, y, k = a[0] + d[0], a[1]+d[1], a[2] if R1-1 <= x <= R2-1 and C1-1 <= y <= C2-1: Flag = True break if 0<=x