Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys

# from collections import Counter, deque, defaultdict
# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N = int(input())
# XY = set()
XY = []
for _ in range(N):
    x, y = [int(x) for x in input().split()]
    # XY.add((x,y))
    XY.append((x, y))

XY.sort()
ans = float("INF")
for i in range(N):
    for j in range(N):
        if i == j:
            continue

        p = XY[i][0] - XY[j][0]
        q = XY[i][1] - XY[j][1]

        T = [0] * N
        for k in range(N):
            if T[k] != 0:
                continue
            T[k] = 1
            curXY = (XY[k][0], XY[k][1])

            for l in range(N):
                if (XY[l][0], XY[l][1]) == ((curXY[0] - p, curXY[1] - q)):
                    T[l] = 2
                    curXY = XY[l]

        # ans = min(T.count(1), ans)
        if ans > T.count(1):
            ans = T.count(1)
            ansP, ansQ = p, q
            # print("ans,p,q = {},{},{}".format(ans, p, q))

if N == 1:
    ans = 1

print(ans)


### FIXED CODE ###

import sys

# from collections import Counter, deque, defaultdict
# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N = int(input())
# XY = set()
XY = []
for _ in range(N):
    x, y = [int(x) for x in input().split()]
    # XY.add((x,y))
    XY.append((x, y))

XY.sort()
ans = float("INF")
for i in range(N):
    for j in range(N):
        if i == j:
            continue

        p = XY[i][0] - XY[j][0]
        q = XY[i][1] - XY[j][1]

        T = [0] * N
        for k in range(N):
            if T[k] != 0:
                continue
            T[k] = 1
            curXY = (XY[k][0], XY[k][1])

            for l in range(N):
                if (XY[l][0], XY[l][1]) == ((curXY[0] - p, curXY[1] - q)):
                    T[l] = 2
                    curXY = XY[l]

        # ans = min(T.count(1), ans)
        if ans > T.count(1):
            ans = T.count(1)
            ansP, ansQ = p, q
            # print("ans,p,q = {},{},{}".format(ans, p, q))

if N == 1:
    ans = 1

print(ans)
### BUGGY CODE ###

n = int(input())
S = list(map(int, input().split()))

n = int(input())
T = list(map(int, input().split()))
cnt = 0

for i in T:
    left = 0
    right = len(S)-1
    center = int( (left+right) / 2 )

    while center >= left and center <= right:
        if S[center] == i:
            cnt += 1
            break
        elif S[center] > i:
            right = center-1
            center = int( (left+right) / 2 )
        elif S[center] < i:
            left = center-1
            center = int( (left+right) / 2 )

print(cnt)


### FIXED CODE ###

n = int(input())
S = list(map(int, input().split()))

n = int(input())
T = list(map(int, input().split()))
cnt = 0

for i in T:
    left = 0
    right = len(S)-1
    center = int( (left+right) / 2 )

    while center >= left and center <= right:
        if S[center] == i:
            cnt += 1
            break
        elif S[center] > i:
            right = center-1
            center = int( (left+right) / 2 )
        elif S[center] < i:
            left = center+1
            center = int( (left+right) / 2 )

print(cnt)
### BUGGY CODE ###

def main():
    n=int(input())
    s=input()
    r = [0]*n
    g = [0]*n
    b = [0]*n
    ans = 0

    dict = {"R":r, "G":g, "B":b}

    for i in range(n):
        dict[s[i]][i] = 1
 
    def rgb_sum(t,i,j):
        for s3 in "RGB":
            if s3 not in t:
                if 2*j-i < n:
                    return sum(dict[s3][j+1:]) - dict[s3][2*j-i]
                else:
                    return sum(dict[s3][j+1:])
                break

    for i in range(n):
        for j in range(i,n):
            s1 = s[i]
            s2 = s[j]
            t = (s1,s2)
            if s1 != s2:
                ans += rgb_sum(t,i,j)

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n=int(input())
    s=input()
    ans = 1

    r_cnt = s.count("R")
    g_cnt = s.count("G")

    ans = r_cnt*g_cnt*(n-r_cnt-g_cnt)
 
    for i in range(n):
        for j in range(i,n):
            s1 = s[i]
            s2 = s[j]
            if s1 != s2:
                t = (s1,s2)
                for s3 in "RGB":
                    if s3 not in t:
                        if 2*j-i < n and s[2*j-i] == s3:
                            ans -= 1
                        continue

    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))
frag = False
ans = 0
for i in range(n):
  frag = False
  for j in range(i):
    if p[i] > p[j]:
      frag = True
  if not frag:
    ans += 1
print(ans)

### FIXED CODE ###

num = (int)(input())
a = input().split()
a = list(map(int, a))

min = a[0]
count = 1
for i in range(num - 1):
  if min > a[i+1]:
    min = a[i+1]
    count += 1
print(count)
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
for i in range(int(input())):
  b,c = map(int,input().split())
  a = [i if b!=i else c for i in a]
  print(sum(a))

### FIXED CODE ###

import collections
N = int(input())
a = list(map(int,input().split()))
ans = sum(a)
cnt = collections.Counter(a)
for i in range(int(input())):
  b,c = map(int,input().split())
  ans += (c-b)*cnt[b]
  cnt[c] += cnt[b]
  cnt[b] = 0
  print(ans)
### BUGGY CODE ###

from functools import lru_cache
h, w, d = map(int, input().split())
pos = [[] for j in range(h*w)]
for a in range(h):
    s = list(map(int, input().split()))
    for g in range(w):
        pos[s[g] -1] = [s[g], a+1, g+1]
q = int(input())
way = []
for rr in range(q):
    way.append(list(map(int, input().split())))
ans = 0


def soo(now, start):
    next = now + d
    prevy, prevx = pos[now - 1][1], pos[now - 1][2]
    nexty, nextx = pos[next - 1][1], pos[next - 1][2]
    return ((abs(nexty - prevy) + abs(nextx - prevx)))

def solve(start, end):
    now = 0
    ans = 0
    for i in range(int((end - start) / d)):
        now = start if not now else now + d
        ans += soo(now, start)
    return ans

for pr, ne in way:
    print(solve(pr, ne))

### FIXED CODE ###

from functools import lru_cache
h, w, d = map(int, input().split())
pos = [[] for j in range(h*w)]
for a in range(h):
    s = list(map(int, input().split()))
    for g in range(w):
        pos[s[g] -1] = [s[g], a+1, g+1]
q = int(input())

def soo(now, start):
    next = now + d
    prevy, prevx = pos[now - 1][1], pos[now - 1][2]
    nexty, nextx = pos[next - 1][1], pos[next - 1][2]
    return ((abs(nexty - prevy) + abs(nextx - prevx)))

def solve(start, end):
    now = 0
    ans = 0
    for i in range(int((end - start) / d)):
        now = start if not now else now + d
        ans += soo(now, start)
    return ans

time = [0 for h in range(h*w)]
for l in range(h*w - d):
    if not time[l + d]:
        time[l+d] = time[l] + (abs(pos[l+d][1] - pos[l][1]) + abs(pos[l+d][2] - pos[l][2]))


@lru_cache(maxsize=None)
def ask(st, en):
    return time[en-1] - time[st-1]


for rr in range(q):
    dd, ff = map(int, input().split())
    print(ask(dd, ff))
### BUGGY CODE ###

n = int(input())
s_list = []
max_count, max_string = 0, []
for _ in range(n):
    s_list.append(input())

for s in s_list:
    if s_list.count(s) == max_count:
        max_string.append(s)
    elif s_list.count(s) > max_count:
        max_count = s_list.count(s)
        max_string.clear()
        max_string.append(s)

max_string = sorted(list(set(max_string)))

for s in max_string:
    print(s)

### FIXED CODE ###

import collections

n = int(input())
s_list = []
for _ in range(n):
    s_list.append(input())
s_data = list(collections.Counter(s_list).most_common())
s_count = int(s_data[0][1])
s_index = 0
for s in s_data:
    if int(s[1]) == s_count:
        s_index += 1
    else:
        break
output = []
for i in range(s_index):
    output.append(s_data[i][0])
output.sort()
for s in output:
    print(s)
### BUGGY CODE ###

import numpy as np

N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = np.array([[0]*3]*N)
dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2]

for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k])

ans = max(dp[N-1])
print(ans)


### FIXED CODE ###

N = int(input())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2]

for i in range(1,N):
  for j in range(3):
    for k in range(3):
      if j != k:
        dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k])

ans = max(dp[N-1])
print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
j=0
for i in range(M):
    A[A.index(max(A[:j+1]))]=A[A.index(max(A[:j+1]))]//2
    j=j+1
    if j==250:
        A.sort(reverse=True)    
        j=0
print(sum(A))

### FIXED CODE ###

import heapq
N,M=map(int,input().split())
A=list(map(lambda x: x*(-1),list(map(int,input().split()))))
A.sort()
B=[]
for i in range(N):
    heapq.heappush(B,A[i])
for i in range(M):
    heapq.heappush(B,(((heapq.heappop(B))*(-1))//2)*(-1))
print((sum(B))*(-1))
### BUGGY CODE ###

K,S = map(int, input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                ans += 1
print(ans)

### FIXED CODE ###

K,S = map(int, input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S-x-y <= K and S-x-y >= 0:
            ans += 1
print(ans)
### BUGGY CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

def solve():
    h, w, m = MAP()
    s = [LIST1() for i in range(m)]
    ay = [0]*h
    ax = [0]*w
    c = [[0]*w for i in range(h)]
    for x in s:
        ay[x[0]] += 1
        ax[x[1]] += 1
        c[x[0]][x[1]] = 1

    my = max(ay)
    mx = max(ax)
    by = [i for i, x in enumerate(ay) if x == my]
    bx = [i for i, x in enumerate(ax) if x == mx]

    ans = my + mx
    tmp = 1
    if len(by)*len(bx) > m:
        tmp = 0
    else:
        for y in by:
            for x in bx:
                if c[y][x] == 0:
                    tmp = 0
                    break
            else:
                continue
            break
    print(ans - tmp)

if __name__ == '__main__':
    solve()


### FIXED CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

def solve():
    h, w, m = MAP()
    s = [LIST1() for i in range(m)]
    ay = [0]*h
    ax = [0]*w
    for x in s:
        ay[x[0]] += 1
        ax[x[1]] += 1

    my = max(ay)
    mx = max(ax)
    
    by = bx = 0
    for y in ay:
        if y == my:
            by += 1
    for x in ax:
        if x == mx:
            bx += 1
            
    ans = my + mx
    tmp = 0
    for x in s:
        if ay[x[0]]+ax[x[1]]==ans:
            tmp += 1
    if tmp == by*bx:
        ans -= 1
    print(ans)
    
if __name__ == '__main__':
    solve()
### BUGGY CODE ###

n,m = map(int,raw_input().split())

arr = []

for i in range(n):
	arr.append(i)

def root(i):
	t = i
	while arr[t] != t:
		t = arr[t]

	return t

for i in range(m):
	query,x,y = map(int,raw_input().split())

	if query == 0:
		arr[root(y)] = x

	else :
		print 1 if root(x) == root(y) else 0


### FIXED CODE ###

n,m = map(int,raw_input().split())

arr = []

for i in range(n):
	arr.append(i)

def root(i):
	t = i
	while arr[t] != t:
		t = arr[t]

	return t

for i in range(m):
	query,x,y = map(int,raw_input().split())

	if query == 0:
		if root(y) == root(x):
			next 
		else :
			arr[root(y)] = root(x)

	else :
		print 1 if root(x) == root(y) else 0
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
for x in range(len(A)):
    a_copy = A[:]
    a_copy[x] = 0
    print(max(a_copy))


### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
copy_A = A[:]
copy_A.remove(maxA)
secondA = max(copy_A)
for x in A:
    if x == maxA:
        print(secondA)
    else:
        print(maxA)
### BUGGY CODE ###

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
S = sr()
# 桁DP, 上から
dp = [0] * 13
dp[0] = 1
for s in S:
    prev = [x for x in dp]
    dp = [0] * 13
    if s == '?':
        loop = range(10)
    else:
        loop = [int(s)]
    for j in range(13):
        for lo in loop:
            dp[(10*j+lo)%13] += prev[j]
    dp = [x%MOD for x in dp]

answer = dp[5]
print(answer%MOD)


### FIXED CODE ###

MOD = 10 ** 9 + 7
S = input()

dp = [0] * 13
dp[0] = 1

for s in S:
  prev = [x for x in dp]
  dp = [0] * 13
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for i in range(13):
    for x in add:
      dp[(10*i+x)%13] += prev[i]
  dp = [x % MOD for x in dp]
  
print(dp[5])
### BUGGY CODE ###

s = str(input())
n = len(s)
ans = 0
mod = 2019

for i in range(n-3):
    nn = int(int(s[i])*1000+int(s[i+1])*100+int(s[i+2])*10+int(s[i+3]))%mod
    if nn == 0:
        ans += 1
    for j in range(i+4,n):
        nn = (nn*10+int(s[j]))%mod
        if nn == 0:
            ans += 1

print(ans)


### FIXED CODE ###

import numpy as np
s = list(map(int,input()))
n = len(s)
ans = 0
mod = 2019
past = s[n-1]
ima = 0
d = dict()
d[s[n-1]] = 1
now = 10
for i in range(1,n):
    ima = (past+s[n-i-1]*now)%mod
    if ima == 0:
        ans += 1
    if ima in d:
        d[ima] += 1
    else:
        d[ima] = 1
    past = ima
    now = (now*10)%mod

for i in d.values():
    ans += i*(i-1)//2

print(ans)
### BUGGY CODE ###

S = input()
N = len(S)
#print(N)
for _ in range(N//2):
    S = S.replace('01','').replace('10','')
    if S.count('01') == 0 and S.count('10') == 0:
        #print("break")
        break
print(N - len(S))

### FIXED CODE ###

S = input()
r = S.count('0')
b = S.count('1')
print(min(r,b)*2)
### BUGGY CODE ###

n = int(input())
s = list(map(int, input().split()))

s.sort()

a = []
a.append(s[-1])
s.pop(-1)
for i in range(n):
    for j in range(len(a)):
        for k in range(len(s)):
            if a[j]>s[-1-k]:
                a.append(s[-1-k])
                s.pop(-1-k)
                break
    if len(a)!=2**(i+1):
        print('No')
        exit()
print('Yes')


### FIXED CODE ###

import time

start = time.time()

n = int(input())
s = list(map(int, input().split()))

s.sort()
s.reverse()

flag = True
for i in range(n):
    a = s[0:2 ** i]
    b = s[2 ** i:2 ** (i + 1)]
    for j in range(len(a)):
        if b[j] >= a[j]:
            flag = False
            break
if flag:
    print('Yes')
    exit()

s.reverse()

a = []
a.append(s[-1])
s.pop(-1)
for i in range(n):
    for j in range(len(a)):
        for k in range(len(s)):
            if a[j]>s[-1-k]:
                a.append(s[-1-k])
                s.pop(-1-k)
                break
        if time.time() - start > 1.8:
            print('Yes')
            exit()
    if len(a)!=2**(i+1):
        print('No')
        exit()

print('Yes')
### BUGGY CODE ###

a = int(input())
i = 1
while True:
  if i % 2 == 0 and i % a == 0:
    print(i)
    break
  else:
    i += 1

### FIXED CODE ###

a = int(input())
if a % 2 == 0:
  print(a)
else:
  print(a * 2)
### BUGGY CODE ###

def expect(num):
    sum
def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    su = 0
    l_sum = []
    i = 0
    while (N-K) >= i:
        tmp_p = p[i:(i+K)]
        if sum(tmp_p) >= su:
            su = sum(tmp_p)
            l_sum = tmp_p
        i += 1

    ans = 0
    for l in l_sum:
        r = l * (l+1)
        r = r/2
        ans += r/l
    print(ans)



    return 0

if __name__ == '__main__':
    main()

### FIXED CODE ###

import math
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))

    P_e = []
    for p in P:
        P_e.append((1 + p)/2)

    P_sum = [0]
    tmp = 0
    for i in range(N):
        tmp += P_e[i]
        P_sum.append(tmp)

    max = 0
    for i in range(K, N+1):
        tmp = P_sum[i] - P_sum[i-K]
        if tmp > max:
            max = tmp

    print(max)
    return 0
if __name__ == '__main__':
    main()
### BUGGY CODE ###

# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [True] * N
l, r = 0, N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())

	for j in range(l, L):
		pass_ids[j] = False
	for j in range(R + 1, r):
		pass_ids[j] = False

	if l > L:
		l = L
	if r < R:
		r = R

print(pass_ids.count(True))

### FIXED CODE ###

# coding: utf-8

N, M = (int(x) for x in input().split())

pass_ids = [x for x in range(N)]

L_max, R_min = 0, N
for i in range(M):
	L, R = (int(x) - 1 for x in input().split())
	
	if L_max < L:
		L_max = L
	if R_min > R:
		R_min = R


if L_max < R_min + 1:
	print(len(list(range(L_max, R_min + 1))))
else:
	print("0")
### BUGGY CODE ###

n, m = list(map(int, input().split(' ')))
aaa = list(map(int, input().split(' ')))
r = 100000
cccbbb = []
for i in range(m):
    b, c = list(map(int, input().split(' ')))
    cccbbb += [c] * b
aaa = sorted(aaa)
cccbbb = sorted(cccbbb)[::-1]
len_cccbbb = len(cccbbb)
len_aaa = len(aaa)
#print(aaa)
#print(cccbbb)
if len_aaa < len_cccbbb:
    #print(([max(a, c) for a, c in zip(aaa, cccbbb[:len_aaa])]))
    print(sum([max(a, c) for a, c in zip(aaa, cccbbb[:len_aaa])]))
elif len_aaa >= len_cccbbb:
    #print(([max(a, c) for a, c in zip(aaa, cccbbb + [0] * (len_aaa - len_cccbbb))]))
    print(sum([max(a, c) for a, c in zip(aaa, cccbbb + [0] * (len_aaa - len_cccbbb))]))


### FIXED CODE ###

import bisect
n, m = list(map(int, input().split(' ')))
aaa = list(map(int, input().split(' ')))
aaa = sorted([-a for a in aaa])[::-1]
len_aaa = len(aaa)

cccbbb = []
for i in range(m):
    b, c = list(map(int, input().split(' ')))
    cccbbb.append((-c, b))
cccbbb = sorted(cccbbb)
ccc = []
for c, b in cccbbb:
    ccc += [c] * b
    if len(ccc) > len_aaa:
        break
ans = 0
for i in range(len_aaa):
    c = ccc[i] if i < len(ccc) else 0
    ans += min(aaa[i], c)
print(abs(ans))
### BUGGY CODE ###

s = input()
n = len(s)
# dp[i][j]:上からi桁目で13で割った余りがjの場合の数
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
        else:
            k = int(s[i])-0
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[n][5])

### FIXED CODE ###

s = input()
n = len(s)
# dp[i][j]:上からi桁目で13で割った余りがjの場合の数
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
        else:
            k = int(s[i])-0
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[n][5])
### BUGGY CODE ###

N = str(input())
tem = int(200000/2019 +1)
possible_nums = [ i*2019 for i in range(tem+1)]

n = 0
for i in range(len(N)+1):

    for j in range(i+1):
        if i-j<4: continue
        num = int(N[j:i])

        if num in possible_nums: n += 1

print(n)



### FIXED CODE ###

S = [int(a) for a in input()[::-1]]
m = 2019
N = len(S)
s = 0
p = 1
X = [0] * 2019
X[0] = 1
ans = 0
for a in S:
    s = (s + a * p) % m
    ans += X[s]
    X[s] += 1
    p = p * 10 % m
 
print(ans)
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path
N, X, Y = map(int, input().split())
G = np.zeros((N, N))
for i in range(N-1):
    G[i,i+1] = 1
    G[i+1,i] = 1
G[X-1, Y-1] = 1
G[Y-1, X-1] = 1
#print(G)
spG = shortest_path(G)
for i in range(1,N):
    print(int(np.count_nonzero(spG==i)/2))

### FIXED CODE ###

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
#print(N)
dlist = [0]*N
for k in range(1, N):
    for i in range(N-k):
        j = i + k
        usek = abs(X -i)+1+abs(j-Y)
        curk = min(k, usek)
        dlist[curk] += 1

for i in dlist[1:]:
    print(i)
### BUGGY CODE ###

from collections import deque

INF = float('inf')

H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
S = [input() for _ in range(H)]

t = [[INF] * W for _ in range(H)]
t[Ch][Cw] = 0
q = deque([(Ch, Cw)])

for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            t[h][w] = -1

while q:
    h, w = q.popleft()
    a = t[h][w]
    if h - 1 >= 0 and t[h - 1][w] > a:
        q.appendleft((h - 1, w))
        t[h - 1][w] = a
    if h + 1 < H and t[h + 1][w] > a:
        q.appendleft((h + 1, w))
        t[h + 1][w] = a
    if w - 1 >= 0 and t[h][w - 1] > a:
        q.appendleft((h, w - 1))
        t[h][w - 1] = a
    if w + 1 < W and t[h][w + 1] > a:
        q.appendleft((h, w + 1))
        t[h][w + 1] = a

    for i in range(max(0, h - 2), min(H - 1, h + 2) + 1):
        for j in range(max(0, w - 2), min(W - 1, w + 2) + 1):
            if t[i][j] <= a + 1:
                continue
            t[i][j] = a + 1
            q.append((i, j))

if t[Dh][Dw] == INF:
    print(-1)
else:
    print(t[Dh][Dw])


### FIXED CODE ###

from collections import deque

INF = float('inf')

H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
S = [input() for _ in range(H)]

t = [[INF] * W for _ in range(H)]
t[Ch][Cw] = 0
q = deque([(Ch, Cw)])

while q:
    h, w = q.popleft()
    a = t[h][w]
    if h - 1 >= 0 and S[h - 1][w] != '#' and t[h - 1][w] > a:
        q.appendleft((h - 1, w))
        t[h - 1][w] = a
    if h + 1 < H and S[h + 1][w] != '#' and t[h + 1][w] > a:
        q.appendleft((h + 1, w))
        t[h + 1][w] = a
    if w - 1 >= 0 and S[h][w - 1] != '#' and t[h][w - 1] > a:
        q.appendleft((h, w - 1))
        t[h][w - 1] = a
    if w + 1 < W and S[h][w + 1] != '#' and t[h][w + 1] > a:
        q.appendleft((h, w + 1))
        t[h][w + 1] = a

    for i in range(max(0, h - 2), min(H - 1, h + 2) + 1):
        for j in range(max(0, w - 2), min(W - 1, w + 2) + 1):
            if S[i][j] == '#':
                continue
            if t[i][j] <= a + 1:
                continue
            t[i][j] = a + 1
            q.append((i, j))

if t[Dh][Dw] == INF:
    print(-1)
else:
    print(t[Dh][Dw])