from heapq import heappush, heappop from collections import deque def solve(): H,W = map(int,input().split()) sx,sy = map(lambda x:int(x)-1, input().split()) gx,gy = map(lambda x:int(x)-1, input().split()) A = [list(input().rstrip()) for _ in range(H)] dx = gx - sx dy = gy - sy vis = [[False]*W for _ in range(H)] dq = deque([(sx,sy)]) vis[sx][sy] = True while dq: x,y = dq.popleft() for dxx,dyy in ((1,0),(-1,0),(0,1),(0,-1)): nx,ny = x+dxx, y+dyy if 0<=nx=2 and small>=2 and is_prime[big] and is_prime[small]) else None for t in range(0, MAXP-big+1): p = big + t q = p - delta if q<2: continue if is_prime[p] and is_prime[q]: return t return None ans = None for V,H in pareto[gx][gy]: if V