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

from collections import deque
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1; cw-=1; dh-=1; dw-=1
area = [list(input()) for _ in range(h)]
dist = [[-1]*w for i in range(h)]

dk = [(i, j, 0) for i in range(-2, 3) for j in range(-2, 3)]
d = []
for i, j, c in dk:
    if (i, j) in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        c = 0
    else:
        c = 1
    d.append((c, i, j))

def Dijkstra(ch, cw):
    """
    Dijkstra法を用いて単一始点終点の最短コストを算出する
    0オリジンとする。
    es: 辺を表す配列。
        es[start]: [cost, en]
    n: 頂点数
    source: 始点
    return: dist　最短距離距離配列。
    """
    import heapq
    used = [[False] * w for i in range(h)] # Falseならば計算対象
    edgelist = []
    # 始点の辺を追加
    for e in d:
        c, y, x = e
        if 0<=ch+y<h and 0<=cw+x<w:
            if used[ch+y][cw+x]: continue
            if area[ch+y][cw+x]=='#': continue
            heapq.heappush(edgelist, (c, ch+y, cw+x))
    used[ch][cw] = True
    dist[ch][cw] = 0
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        cost, y, x = minedge
        if used[y][x]:
            continue
        dist[y][x] = cost
        used[y][x] = True
        if y==dh and x==dw:
            return dist
        for e in d:
            next_cost, next_y, next_x = e
            if 0<=y+next_y<h and 0<=x+next_x<w:
                if used[y+next_y][x+next_x]: continue
                if area[y+next_y][x+next_x]=='#': continue
                heapq.heappush(edgelist, (dist[y][x]+next_cost, y+next_y, x+next_x))
    return dist

dist = Dijkstra(ch, cw)
print(dist[dh][dw])

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1; cw-=1; dh-=1; dw-=1
area = [list(input()) for _ in range(h)]
inf = 10**100
dist = [[inf]*w for i in range(h)]

dwalk = [(0, 1), (0, -1), (1, 0), (-1, 0)]

def Dijkstra(ch, cw):
    import heapq
    edgelist = [(0, ch, cw)]
    heapq.heapify(edgelist)
    dist[ch][cw] = 0
    while len(edgelist):
        cost, y, x = heapq.heappop(edgelist)
        if y==dh and x==dw:
            return dist
        if dist[y][x] < cost: continue
        for next_y, next_x in dwalk:
            if 0<=y+next_y<h and 0<=x+next_x<w:
                if area[y+next_y][x+next_x]=='#': continue
                if dist[y+next_y][x+next_x]>cost:
                    dist[y+next_y][x+next_x] = cost
                    heapq.heappush(edgelist, (cost, y+next_y, x+next_x))
        for next_y in range(-2, 3):
            for next_x in range(-2, 3):
                    if 0<=y+next_y<h and 0<=x+next_x<w:
                        if area[y+next_y][x+next_x]=='#': continue
                        if dist[y+next_y][x+next_x]>cost+1:
                            dist[y+next_y][x+next_x] = cost+1
                            heapq.heappush(edgelist, (cost+1, y+next_y, x+next_x))
    return dist

dist = Dijkstra(ch, cw)
if dist[dh][dw] == inf:
    print(-1)
else:
    print(dist[dh][dw])
### BUGGY CODE ###

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

list_a.sort()

counts = []

for i in range(0, 100000):
    if (i+1) in list_a:
        counts.append(list_a.count(i+1))
    else:
        counts.append(0)

q = int(input())
ans = sum(list_a)

for i in range(q):
    b, c = map(int, input().split())

    ans += counts[b-1] * (c - b)

    counts[c-1] += counts[b-1]
    counts[b-1] = 0

    print(ans)


### FIXED CODE ###

import numpy as np

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

counts = np.zeros(100000, dtype=int)

ans = 0

for i in range(len(list_a)):
    counts[list_a[i]-1] += 1
    ans += list_a[i]

q = int(input())

for i in range(q):
    b, c = map(int, input().split())

    ans += counts[b-1] * (c - b)

    counts[c-1] += counts[b-1]
    counts[b-1] = 0

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

# Problem: https://atcoder.jp/contests/abc051/tasks/abc051_b
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(K, S):
    result = 0
    # algorithm
    for x in range(0, K+1):
        for y in range(0, K+1):
            for z in range(0, K+1):
                if x+y+z == S:
                    result = result + 1
    return result


if __name__ == "__main__":
    K, S = MI()
#    print("K={} S={}".format(K, S))
    print("{}".format(solver(K, S)))


### FIXED CODE ###

# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest051-B
#  https://atcoder.jp/contests/abc051/tasks/abc051_b
from itertools import product
def  queueAnswer(maxValue,sumNumber):
	baseList = list(range(0,maxValue+1,1))
	xyPool = product(baseList,baseList)
	counter = 0
	for x,y in xyPool:
		z = sumNumber - x - y
		if ( 0 <= z ) and ( z <= maxValue):
			counter = counter + 1

	answer = counter
	return answer


if __name__ == '__main__':
	k,s = map(int,input().strip().split(' '))
	solution=queueAnswer(k,s)
	print(solution)
### BUGGY CODE ###

mod = 998244353
N,K = map(int,input().split())
move = []
for _ in range(K):
    x,y = map(int,input().split())
    for i in range(x,y+1):
        move.append(i)
move.sort()
move = set(move)
memo = [0]*(N+1)
memo[1] = 1
for i in range(1,N):
    if 0<memo[i]:
        for j in move:
            if i+j<=N:
                memo[i+j] += memo[i]
            else:
                break
        
print(memo[-1]%mod)

### FIXED CODE ###

mod = 998244353
N,K = map(int,input().split())
move = [list(map(int,input().split())) for _ in range(K)]

dp = [0]*(N+1)
dp_sum = [0]*(N+1)
dp[1] = dp_sum[1] = 1
for i in range(2,N+1):
    for l,r in move:
        if 0<i-l:
            dp[i] += dp_sum[i-l]
            if 0<i-r-1:
                dp[i] -= dp_sum[i-r-1]
        dp[i] %= mod
    dp_sum[i] = dp_sum[i-1] + dp[i]
            
print(dp[-1]%mod)
### BUGGY CODE ###

import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    ans = (0, 0, 0)
    for h in range(1, 3501):
        for n in range(1, 3501):
            # 式をwについて解いた
            num = N * n * h
            denom = 4 * h * n - N * (h + n)
            if denom > 0 and num % denom == 0:
                w = num // denom
                ans = (h, n, w)
                break

    print(*ans)

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    ans = (0, 0, 0)
    for h in range(1, 3501):
        for n in range(1, 3501):
            # 式をwについて解いた
            num = N * n * h
            denom = 4 * h * n - N * (h + n)
            if denom > 0 and num % denom == 0:
                w = num // denom
                ans = (h, n, w)
                break

    print(*ans)

if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

# マージO(n)かかっちゃう
class union_find(object):
 	"""union-find tree"""
 	def __init__(self, length):
 		self.length = length
 		self.unionnumber=0
 		self.unionlist=[[]]
 		self.num=list(-1 for i in range(length))

 	def unite(self,i,j):
 		if self.num[i]==-1:
 			if self.num[j]==-1:
 				self.unionlist[self.unionnumber].extend([i,j])
 				self.num[i]=self.unionnumber
 				self.num[j]=self.unionnumber
 				self.unionnumber+=1
 				self.unionlist.append([])
 			else:
 				tmp=i 
 				i=j 
 				j=tmp 
 		if self.num[i]!=-1:
 			if self.num[j]!=-1:
 				if self.num[i]==self.num[j]:
 					pass
 				else:
 					self.unionlist[self.num[i]].extend(self.unionlist[self.num[j]])
 					tmp=self.num[j]
 					for k in self.unionlist[self.num[j]]:
 						self.num[k]=self.num[i]
 					self.unionlist[tmp]="del"
 			else:
 				self.num[j]=self.num[i]
 				self.unionlist[self.num[i]].append(j)

 	def same(self,i,j):
 		if self.num[i]==-1 or self.num[j]==-1:
 			return(False)
 		else:
 			return(self.num[i]==self.num[j])


N,K,L=list(map(int,input().split()))
road=union_find(N)
rail=union_find(N)

for i in range(K):
	a=list(map(int,input().split()))
	road.unite(a[0]-1,a[1]-1)

for i in range(L):
	a=list(map(int,input().split()))
	rail.unite(a[0]-1,a[1]-1)

res=[0 for i in range(N)]
for i in range(N):
	if res[i]==0:
		n=road.num[i]
		A=road.unionlist[n]
		m=rail.num[i]
		B=set(rail.unionlist[m]).intersection(A)
		l=len(B)
		if l==0:
			B=[i]
			l=1
		for j in B:
			res[j]=l

for i in res:
	print(i,end=" ")
print("")
















### FIXED CODE ###

# マージO(n)かかっちゃう
class union_find:
	def __init__(self, size):
		# 負の値はルート (集合の代表) で集合の個数
		# 正の値は次の要素を表す
		self.size=size
		self.table = [-1 for _ in range(size)]
		self.num=[0 for i in range(size)]

	# 集合の代表を求める
	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			# 経路の圧縮
			self.table[x] = self.find(self.table[x])
			return(self.table[x])

	# 併合
	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] <= self.table[s2]:
				# 小さいほうが個数が多い
				self.table[s1] += self.table[s2]
				self.table[s2] = s1
			else:
				self.table[s2] += self.table[s1]
				self.table[s1] = s2
			return(True)
		return(False)

	def definite(self):
		for i in range(self.size):
			self.num[i]=self.find(i)
		return(True)


N,K,L=list(map(int,input().split()))
road=union_find(N)
rail=union_find(N)

for i in range(K):
	a=list(map(int,input().split()))
	road.unite(a[0]-1,a[1]-1)

for i in range(L):
	a=list(map(int,input().split()))
	rail.unite(a[0]-1,a[1]-1)

road.definite()
rail.definite()

dic={}
# print(road.num,rail.num)

for i in range(N):
	key=str(road.num[i])+":"+str(rail.num[i])
	if key in dic:
		dic[key].append(i)
	else:
		dic[key]=[i]

# print(dic)
res=[0 for i in range(N)]
for i in dic.values():
	l=len(i)
	for j in i:
		res[j]=l

for i in res:
	print(i,end=" ")
print("")
### BUGGY CODE ###

"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    s = input()

    cnt = [0] * 2019
    # print(cnt)
    cnt[0] = 1
    ans = 0
    b = 0
    t = 1
    for i in range(len(s)):
        b = b + int(s[len(s)-i-1]) * t
        amari = b % 2019
        cnt[amari] += 1
        t *= 10 % 2019

    for i in cnt:
        ans += i * (i - 1) // 2
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

s = input()[::-1]

sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10
    d %= 2019
    cnts[sum_of_digits] += 1

ans = 0

for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

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

k,s=map(int,input().split())
ans=0
for x in range(k+1):
  if x>s:break
  for y in range(k+1):
    if x+y>s:break
    for z in range(k+1):
      if x+y+z > s:break
      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):
    z=s-x-y
    ans += 1 if z>=0 and z<=k else 0
print(ans)
### BUGGY CODE ###

import sys
from collections import deque, Counter
def input(): return sys.stdin.readline().rstrip()

def main():
    N, X, Y = map(int, input().split())

    c = Counter()
    for i in range(1, N+1):
        dist = [-1] * (N+1)
        dist[i] = 0
        q = deque()
        q.append(i)
        while q:
            j = q.popleft()
            if j < N and dist[j+1] < 0:
                q.append(j+1)
                dist[j+1] = dist[j] + 1
            if j > 1 and dist[j-1] < 0:
                q.append(j-1)
                dist[j-1] = dist[j] + 1
            if j == X and dist[Y] < 0:
                q.append(Y)
                dist[Y] = dist[j] + 1
            if j == Y and dist[X] < 0:
                q.append(X)
                dist[X] = dist[j] + 1
        c += Counter(dist)
    for i in range(1, N):
        print(c[i]// 2)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, X, Y = map(int, input().split())

    ans = [0] * N
    for i in range(1, N):
        for j in range(i+1, N+1):
            if i >= Y or j <= X:
                ans[j-i] += 1
            else:
                ans[min(j-i, abs(X-i) + abs(Y-j)+1)] += 1
    print(*ans[1:], sep='\n')

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

n = int(input())+1
num = 10**9+7
power = 1

for i in range(1, n):
    power = power * i

ans = power % num
print(ans)

### FIXED CODE ###

n = int(input()) + 1
mod = 10**9 + 7
power = 1

for i in range(1, n):
    power *= i
    power %= mod

print(power)
### BUGGY CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    B = Counter(A[:i] + A[i+1:])
    #print(B)
    ans = 0
    for n in B.values():
        ans += n*(n-1)//2
    print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)

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

for a in A:
    k = B[a]
    print(ans - (k*(k-1)//2)+((k-1)*(k-2)//2))
### BUGGY CODE ###

from collections import Counter
from operator import mul
from functools import reduce
def combinations_count2(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

#
N=int(input())
A=list(map(int,input().split()))
#
hoge=Counter(A)
ans=0
for i in hoge.values():
    if i>=2:
        ans += combinations_count2(i, 2)
for i in range(N):
    print(ans-A.count(A[i])+1)



### FIXED CODE ###

from collections import Counter
from operator import mul
from functools import reduce
def combinations_count2(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

#
N=int(input())
A=list(map(int,input().split()))
#
hoge=Counter(A)
ans=0
for i in hoge.values():
    if i>=2:
        ans += combinations_count2(i, 2)
for i in range(N):
    print(ans-hoge[A[i]]+1)
### BUGGY CODE ###

from heapq import heappop, heappush
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

g = [[10**10 for _ in range(n)] for __ in range(n)]

for _ in range(m):
    l, r, c = map(int, input().split())
    g[l-1][r-1] = min(g[l-1][r-1], c)
    for i in range(l, r):
        g[i][i-1] = 0


def dijkstra(s, n, edges):
    # edges[i][j] : the cost of i→j
    # import 'heap'
    d = [10**13] * n
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in enumerate(edges[u]):
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d


d = dijkstra(0, n, g)
print(d[n-1] if d[n-1] != 10**10 else -1)


### FIXED CODE ###

from heapq import heappop, heappush

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

g = [[] for __ in range(n)]

for _ in range(m):
    l, r, c = map(int, input().split())
    g[l-1].append((r-1, c))

for i in range(1, n):
    g[i].append((i-1, 0))


d = [10**18] * n
d[0] = 0
q = [(0, 0)]
while q:
    dist_u, u = heappop(q)
    if d[u] < dist_u:
        continue
    for v, c in g[u]:
        if d[v] > dist_u + c:
            d[v] = dist_u + c
            heappush(q, (d[v], v))


print(d[n-1] if d[n-1] != 10**18 else -1)
### BUGGY CODE ###

from heapq import heappop, heappush
INF = 10**30

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[a, b)
	def Get(self, a, b, k=0, l=0, r=-1):
		if r < 0:
			r = self.n

		if a >= r or b <= l:
			return INF
		elif a <= l and b >= r:
			return self.node[k]
		else:
			vl = self.Get(a, b, 2*k+1, l, (l+r)//2)
			vr = self.Get(a, b, 2*k+2, (l+r)//2, r)
			return min(vl, vr)

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

even, odd = Rmin(n), Rmin(n)
for i in range(n):
	if i%2 == 0:
		even.Update(i, a[i]*(10**7) + i)
	else:
		odd.Update(i, a[i]*(10**7) + i)

d = dict()

def search(l, r):
	if l%2 == 0:
		p = even.Get(l, r+1)
		q = odd.Get(p%(10**7)+1, r+1)
	else:
		p = odd.Get(l, r+1)
		q = even.Get(p%(10**7)+1, r+1)
	return p, q

x, y = search(0, n-1)
d[x%(10**7)] = (y, 0, n-1)
que = [x]
ans = []

while que:
	x = heappop(que)
	y, l, r = d[x%(10**7)]
	ans += [x//(10**7), y//(10**7)]

	if l != x%(10**7):
		p, q = search(l, x%(10**7)-1)
		d[p%(10**7)] = (q, l, x%(10**7)-1)
		heappush(que, p)

	if r != y%(10**7):
		p, q = search(y%(10**7)+1, r)
		d[p%(10**7)] = (q, y%(10**7)+1, r)
		heappush(que, p)

	if x%(10**7)+1 != y%(10**7):
		p, q = search(x%(10**7)+1, y%(10**7)-1)
		d[p%(10**7)] = (q, x%(10**7)+1, y%(10**7)-1)
		heappush(que, p)

print(*ans)

### FIXED CODE ###

from heapq import heappop, heappush
INF = 10**30

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = INF
		while L < R:
			if R & 1:
				R -= 1
				s = min(s, self.node[R-1])			
			if L & 1:
				s = min(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

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

even, odd = Rmin(n), Rmin(n)
for i in range(n):
	if i%2 == 0:
		even.Update(i, a[i]*(10**7) + i)
	else:
		odd.Update(i, a[i]*(10**7) + i)

d = dict()

def search(l, r):
	if l%2 == 0:
		p = even.Get(l, r+1)
		q = odd.Get(p%(10**7)+1, r+1)
	else:
		p = odd.Get(l, r+1)
		q = even.Get(p%(10**7)+1, r+1)
	return p, q

x, y = search(0, n-1)
d[x%(10**7)] = (y, 0, n-1)
que = [x]
ans = []

while que:
	x = heappop(que)
	y, l, r = d[x%(10**7)]
	ans += [x//(10**7), y//(10**7)]

	if l != x%(10**7):
		p, q = search(l, x%(10**7)-1)
		d[p%(10**7)] = (q, l, x%(10**7)-1)
		heappush(que, p)

	if r != y%(10**7):
		p, q = search(y%(10**7)+1, r)
		d[p%(10**7)] = (q, y%(10**7)+1, r)
		heappush(que, p)

	if x%(10**7)+1 != y%(10**7):
		p, q = search(x%(10**7)+1, y%(10**7)-1)
		d[p%(10**7)] = (q, x%(10**7)+1, y%(10**7)-1)
		heappush(que, p)

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

from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]
d = defaultdict(int)
ans = 0

def paint(str, ptn):
  red = ''.join(s for i, s in enumerate(str) if 2**i & ptn)
  blue = ''.join(s for i, s in enumerate(str) if not 2**i & ptn)
  return (red, blue)

for i in range(2**N):
  d[paint(first, i)] += 1
  
for i in range(2**N):
  ans += d[paint(last, i)]

print(ans)

### FIXED CODE ###

from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  p = ['', '']
  for i in range(N):
    p[int(2**i & ptn > 0)] += str[i]
  return tuple(p)

for i in range(2**N):
  d[paint(first, i)] += 1
  
for i in range(2**N):
  ans += d[paint(last, i)]
  
print(ans)
### BUGGY CODE ###

s = input()
q = int(input())
for i in range(q):
  t=list(input().split())
  if len(t) == 1:#一つしか入力されていない
    s = s[::-1]#逆にする
  else:
    if t[1] == '1':
      s = t[2] + s
    else:
      s = s + t[2]
print(s)

### FIXED CODE ###

s = input()
q = int(input())
r = False#ひっくり返されたか
f = ''#in front of#逆転しているので最後に戻しましょう
b = '' #behind
for i in range(q):
  t=list(input().split())
  if len(t) == 1:#一つしか入力されていない
    r = not(r)
  else:
    if (t[1] == '1' and r == False):
      f += t[2]
    elif (t[1] == '2' and r == True):
      f += t[2]
    else:
      b += t[2]
s = f[::-1] + s + b
if r:
  print(s[::-1])
else:
  print(s)
### BUGGY CODE ###

from collections import defaultdict
H, W, M = map(int, input().split())
rows = {i: 0 for i in range(H)}
cols = {i: 0 for i in range(W)}
d = defaultdict(int)
for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    rows[h] += 1
    cols[w] += 1
    d[(h,w)] += 1
max_rows = [kv for kv in rows.items() if kv[1] == max(rows.values())]
max_cols = [kv for kv in cols.items() if kv[1] == max(cols.values())]
non_dup = False
ans = max_rows[0][1] + max_cols[0][1]
for kh, vh in max_rows:
    for kw, vw in max_cols:
        if d[(kh, kw)] == 0:
            non_dup = True
            break
if not non_dup:
    ans -= 1
print(ans)

### FIXED CODE ###

from collections import defaultdict
H, W, M = map(int, input().split())
rows = {i: 0 for i in range(H)}
cols = {i: 0 for i in range(W)}
d = defaultdict(int)
for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    rows[h] += 1
    cols[w] += 1
    d[(h,w)] += 1
mr = max(rows.values())
mc = max(cols.values())
max_rows = [kv for kv in rows.items() if kv[1] == mr]
max_cols = [kv for kv in cols.items() if kv[1] == mc]
non_dup = False
ans = max_rows[0][1] + max_cols[0][1]
flg = False
for kh, vh in max_rows:
    for kw, vw in max_cols:
        if d[(kh, kw)] == 0:
            non_dup = True
            flg = True
            break
    if flg:
        break
if not non_dup:
    ans -= 1
print(ans)