Harryxun/stf_run huggingface dataset:
N, M = map(int, raw_input().split())

a, b = [map(int, raw_input().split()) for _ in xrange(N)]
c, d = [map(int, raw_input().split()) for _ in xrange(M)]

for i in xrange(N):
    for j in xrange(M):

        d = abs(a[i]-c[j]) + abs(b[i]-d[j])

        if j == 0:
            t = d
            ans = 1

        elif t > d:
            t = d
            ans = j+1

    print ans

### FIXED CODE ###

import math

N, M = map(int, raw_input().split())

a, b, c, d = [], [], [], []

for i in xrange(N):
    s = map(int, raw_input().split())
    a.append(s[0])
    b.append(s[1])

for i in xrange(M):
    s = map(int, raw_input().split())
    c.append(s[0])
    d.append(s[1])


ans = 0
t = 0
for i in xrange(N):
    for j in xrange(M):
        if j == 0:
            t = abs(a[i]-c[j]) + abs(b[i]-d[j])
            ans = 1
        elif t > abs(a[i]-c[j]) + abs(b[i]-d[j]):
            t = abs(a[i]-c[j]) + abs(b[i]-d[j])
            ans = j+1
        #print "t = %d" % t
        #print "ans=%d" % ans
    print ans
import sys
input = sys.stdin.readline
import numpy as np
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = max(max(a),max(b)).bit_length()+1
b = np.array(a,dtype=np.int32)
b = np.array(b,dtype=np.int32)
ans = 0
for i in range(1,x+1):
  c = a&(1<<i)-1
  d = b&(1<<i)-1
  d.sort()
  t = 1<<(i-1)
  anstmp = 0
  for j in range(n):
    y = c[j]
    t1 = np.searchsorted(d,t-y)
    t2 = np.searchsorted(d,2*t-y)
    t3 = np.searchsorted(d,3*t-y)
    anstmp += (t2-t1)+(n-t3)
  if anstmp%2:
    ans += t
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = max(max(a),max(b)).bit_length()+1
a = np.array(a,dtype=np.int32)
b = np.array(b,dtype=np.int32)
ans = 0
for i in range(1,x+1):
  c = a&(1<<i)-1
  d = b&(1<<i)-1
  d.sort()
  t = 1<<(i-1)
  anstmp = 0
  t1 = np.searchsorted(d,t-c).sum()
  t2 = np.searchsorted(d,2*t-c).sum()
  t3 = np.searchsorted(d,3*t-c).sum()
  anstmp += (t2-t1)+(n-t3)
  if anstmp%2:
    ans += t
print(ans)
S = input().strip()

weather = ["Sunny", "Cloudy", "Rainy"]


idx = weather.index(S) + 1
if idx > len(weather):
    print(weather[0])
else:
    print(weather[idx])


### FIXED CODE ###

S = input().strip()

weather = ["Sunny", "Cloudy", "Rainy"]


idx = weather.index(S) + 1
if idx >= len(weather):
    print(weather[0])
else:
    print(weather[idx])
N = int(input())
A = list(map(int,input().split()))
A = [0]
dp = [[0] * (N+1) for _ in range(N+1)]

#半開区間で考える⇒[i,j)での最適解
for w in range(1,N+1):#区間の残り数
    for l in range(N):# 左端
        r = l + w#右端
        if r > N:
            continue
        elif (N-k) % 2 == 0:#太郎
            #print(i,x)
            dp[l][x] = max(dp[l+1][x] + A[l], dp[l][r-1] + A[r-1])
        elif (N-k) % 2 == 1:#次郎
            #print(i,x)
            dp[l][x] = min(dp[l+1][x] - A[l], dp[l][r-1] - A[r-1])
            
print(dp)

### FIXED CODE ###

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

for i in range(N+1):
    dp[i][i] = 0

for k in range(1,N+1):#区間の残り数
    for i in range(N):#左端
        x = i+k#右端
        if x > N:
            continue
        elif (N-k) % 2 == 0:#太郎
            #print(i,x)
            dp[i][x] = max(dp[i+1][x] + A[i], dp[i][x-1] + A[x-1])
        elif (N-k) % 2 == 1:#次郎
            #print(i,x)
            dp[i][x] = min(dp[i+1][x] - A[i], dp[i][x-1] - A[x-1])
            
print(dp[0][N])
import copy

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b

def main():
    n, m = map(int, input().split())
    # これだと72がREになる
    A = [int(x) for x in input().split()]
    # A_s = set(A)
    # これだと74も78もREになる
    # A = [int(x) for x in input().split()]
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for i in A:
        if (a_lcm / 2) % i == 0:
        # if (a_lcm / i) % 2 == 0: 
            print(0)
            exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    else:
        # # あとは定数倍の数調べて終わり
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
N,K=map(int,input().split())
print(K*((K-1)^^(N-1)))

### FIXED CODE ###

N,K=map(int,input().split())
print(K*((K-1)**(N-1)))
S =input()
T = input()

s = list(S)
ans = 0

if B.lower() == T.lower():
        ans +=1

for _ in  range(len(s)-1):
    A=s[-1]
    s.pop(-1)
    s.insert(0,A)
    print(s)
    B=''.join(s)
    if B.lower() == T.lower():
        ans +=1
if ans != 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

S =input()
T = input()

s = list(S)
ans = 0

if S.lower() == T.lower():
        ans +=1

for _ in  range(len(s)-1):
    A=s[-1]
    s.pop(-1)
    s.insert(0,A)
    #print(s)
    B=''.join(s)
    if B.lower() == T.lower():
        ans +=1
if ans != 0:
    print('Yes')
else:
    print('No')
import numpy as np
import sys

def main(args):
    a = int(args[0])
    b = int(args[1])
    if 6 <= a and a <= 12:
        v = b//2
    elif a <= 5:
        v = 0
    else:
        v = b
    print(v)

main(sys.argv[1:3])

### FIXED CODE ###

import numpy as np
from sys import stdin
#sys.setrecursionlimit(10**6) 

def main():
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    if 6 <= a and a <= 12:
        v = b//2
    elif a <= 5:
        v = 0
    else:
        v = b
    print(v)

if __name__ == "__main__":
    main()
class Cmb:
    def __init__(self, N, mod=10**9+7):
        self.fact = [1,1]
        self.fact_inv = [1,1]
        self.inv = [0,1]
        
        """ 階乗を保存する配列を作成 """
        for i in range(2, N+1):
            self.fact.append((self.fact[-1]*i) % mod)
            self.inv.append((-self.inv[mod%i] * (mod//i))%mod)
            self.fact_inv.append((self.fact_inv[-1]*self.inv[i])%mod)
    
    """ 関数として使えるように、callで定義 """
    def __call__(self, n, r, mod=10**9+7):
        if (r<0) or (n<r):
            return 0
        return self.fact[n] * self.fact_inv[n-r] % mod

from collections import deque
n,k = map(int,input().split())
mod = 10**9 + 7
es = [[] for _ in range(n+1)]
d = [0]*(n+1)
for _ in range(n-1):
    a,b = map(int,input().split())
    es[a].append(b)
    es[b].append(a)
    d[a] += 1
    d[b] += 1

root = -1
for i in range(1, n+1):
    if d[i] == 1:
        root = i
        break

num_child = [0]*(n+1)
que = deque([])
for c in es[root]:
    que.append((root, c))

while que:
    p,c = que.pop()
    num_child[p] += 1
    for nx in es[c]:
        if nx!=p:
            que.append((c, nx))

c = Cmb(N=n)
ans = k

for e,child in enumerate(num_child[1:]):
    if e+1==root:
        cand = k-1
    else:
        cand = k-2
    if child==0:
        continue
    else:
        ans = ans*(c(cand, child)) % mod
print(ans%mod)

### FIXED CODE ###

class Cmb:
    def __init__(self, N, mod=10**9+7):
        self.fact = [1,1]
        self.fact_inv = [1,1]
        self.inv = [0,1]
        
        """ 階乗を保存する配列を作成 """
        for i in range(2, N+1):
            self.fact.append((self.fact[-1]*i) % mod)
            self.inv.append((-self.inv[mod%i] * (mod//i))%mod)
            self.fact_inv.append((self.fact_inv[-1]*self.inv[i])%mod)
    
    """ 関数として使えるように、callで定義 """
    def __call__(self, n, r, mod=10**9+7):
        if (r<0) or (n<r):
            return 0
        return self.fact[n] * self.fact_inv[n-r] % mod

from collections import deque
n,k = map(int,input().split())
mod = 10**9 + 7
es = [[] for _ in range(n+1)]
d = [0]*(n+1)
for _ in range(n-1):
    a,b = map(int,input().split())
    es[a].append(b)
    es[b].append(a)
    d[a] += 1
    d[b] += 1

root = -1
for i in range(1, n+1):
    if d[i] == 1:
        root = i
        break

num_child = [0]*(n+1)
que = deque([])
for c in es[root]:
    que.append((root, c))

while que:
    p,c = que.pop()
    num_child[p] += 1
    for nx in es[c]:
        if nx!=p:
            que.append((c, nx))

c = Cmb(N=k)
ans = k

for e,child in enumerate(num_child[1:]):
    if e+1==root:
        cand = k-1
    else:
        cand = k-2
    if child==0:
        continue
    else:
        ans = ans*(c(cand, child)) % mod

print(ans%mod)
s = input()
t = input()

#dp[i][j] => s[i], t[j]までの最長部分文字列

dp = [[0] * (len(t) + 1) for j in range(len(s) + 1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j] + 1
        else:
            c, d = dp[i][j-1], dp[i-1][j]
            #上か左の長いほうを入れる
            if c < d:
                dp[i][j] = d
            else:
                dp[i][j] = c
def make_ans(a, b):
    if a < 0 or b < 0:
        return 
    if s[a - 1] == t[b - 1]:
        make_ans(a-1,b-1)
        ans.append(s[a-1])
    else:
        if dp[a - 1][b] > dp[a][b - 1]:
            make_ans(a-1,b)
        else:
            make_ans(a,b-1)

ans = []
make_ans(len(s),len(t))
print("".join(ans))



### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
s = input()
t = input()

#dp[i][j] => s[i], t[j]までの最長部分文字列

dp = [[0] * (len(t) + 1) for j in range(len(s) + 1)]
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1] == t[j-1]:
            x = 1
        else:
            x = 0
        dp[i][j] = max(dp[i-1][j-1] + x, dp[i-1][j], dp[i][j-1])


def make_ans(a, b):
    if a ==  0 or b == 0:
        return 
    if s[a-1] == t[b-1]:
        make_ans(a-1,b-1)
        ans.append(s[a-1])
    else:
        if a == 0:
            make_ans(a, b - 1)
        elif b == 0:
            make_ans(a - 1,b)
        else:
            if dp[a - 1][b] > dp[a][b - 1]:
                make_ans(a-1,b)
            else:
                make_ans(a,b-1)

ans = []
make_ans(len(s),len(t))
print("".join(ans))
n,m=list(map(int,input().split()))
par=[i for i in range(n)]
ro=dict(int)
for i in range(n):
    ro[i]=1
def root(i):
    if par[i]==i:
        return i
    else:
        return root(par[i])

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry
        ro[ry]+=ro[rx]
        ro[rx]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    unite(a,b)


# for i in range(n):
#     ro[root(i)]+=1

print(max(ro.values()))

### FIXED CODE ###

n,m=list(map(int,input().split()))
par=[i for i in range(n)]
ro=dict()

for i in range(n):
    ro[i]=1
def root(i):
    if par[i]==i:
        return i
    else:
        a=root(par[i])
        par[i]=a
        return a

def unite(x,y):
    rx=root(x)
    ry=root(y)
    if rx!=ry:
        par[rx]=ry
        ro[ry]+=ro[rx]
        ro[rx]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    a-=1
    b-=1
    unite(a,b)

print(max(ro.values()))
N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
num=[0]*(1+N+max(a))

for i in range(N):
  w.append(1+i+a[i])
  s.append(1+i-a[i])
  num[1+i-a[i]]+=1
for i in range(N):
  count+=num[w[i]]
print(count)

### FIXED CODE ###

N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
num=[0]*N
maxi=max(a)
for i in range(N):
  s.append(1+i-a[i])
  if 1+i+a[i]<N:
    num[1+i+a[i]]+=1
for i in range(N):
  if s[i]>=0:
    count+=num[s[i]]
print(count)
a,b = map(int,input().split())
print(b+a)

### FIXED CODE ###

s,t = map(str,input().split())

print(t+s)
N,M = [int(i) for i in input().split(' ')]
itemList = np.array([int(i) for i in input().split(' ')])

for _ in range(M):
    itemList[np.argmax(itemList)] //= 2        

print(sum(itemList))

### FIXED CODE ###

from heapq import heappush, heappop
import math

N,M = [int(i) for i in input().split(' ')]
itemList = [int(i) for i in input().split(' ')]
heap = []

for i in itemList:
    heappush(heap, -i)

for _ in range(M):
    heappush(heap, math.ceil(heappop(heap)/2))
print(-sum(heap))
S = input()

if S.count(A) >= 1 and S.count(B) >= 0 :
    print("Yes")
else :
    print("No")

### FIXED CODE ###

S = input()

if S.count("A") >= 1 and S.count("B") >= 1 :
    print("Yes")
else :
    print("No")
n =  int(input())
arr = input().split()
arr = [int(x) for x in arr]
def hhhh(arr):
    res = []
    for j in range(1,len(arr)):
        for i in range(j):
            #print(arr[i:j])
            if all([arr[i:j][k] >= arr[i:j][k+1] for k in range(len(arr[i:j])-1)]):
                    res.append(j-i)
                    
    
    return max(res)
hhhh(arr)

### FIXED CODE ###

n =  int(input())
arr = input().split()
arr = [int(x) for x in arr]
counts = []
temp = 0
for i in range(n-1):
    if arr[i] >= arr[i+1]:
        temp += 1
        #print(temp)
        counts.append(temp)
    else:
        #counts.append(temp)
        temp = 0
if not counts:
    print(0)
else:
    print(max(counts))
import math
import sys
import itertools
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
x,y = IL()
N = len(s)

xlist = []
ylist = []

f = 0
cnt = 0
for i in range(N):
  if s[i] == "F":
    cnt += 1
  elif s[i] == "T":
    if f == 0:
      xlist.append(cnt)
      f = 1
    else:
      ylist.append(cnt)
      f = 0
    cnt = 0
else:
  if f == 0:
    xlist.append(cnt)
  else:
    ylist.append(cnt)

#print(xlist)
#print(ylist)

Xsum = sum(xlist)
Ysum = sum(ylist)

if (Xsum-x)%2 != 0:
  print("No")
  exit()
else:
  Xnum = (Xsum-x)//2
if (Ysum-y)%2 != 0:
  print("No")
  exit()
else:
  Ynum = (Ysum-y)//2

XDP = [[0]*(Xnum+2) for _ in range(len(xlist)+2)]
YDP = [[0]*(Ynum+2) for _ in range(len(ylist)+2)]

XDP[0][0] = 1
XDP[1][0] = 1
if s[0] == "F":
  if xlist[0] <= Xnum+1:
    XDP[1][xlist[0]] = 1
  else:
    print("No")
    exit()
YDP[0][0] = 1

for i in range(2,len(xlist)+1):
  for j in range(Xnum+1):
    if XDP[i-1][j] == 1:
      XDP[i][j] = 1
      if j+xlist[i-1] < Xnum+1:
        XDP[i][j+xlist[i-1]] = 1
#print(XDP)
for i in range(1,len(ylist)+1):
  for j in range(Ynum+1):
    if YDP[i-1][j] == 1:
      YDP[i][j] = 1
      if j+ylist[i-1] < Ynum+1:
        YDP[i][j+ylist[i-1]] = 1
#print(YDP)
if XDP[-2][-2] == 1 and YDP[-2][-2] == 1:
  print("Yes")
else:
  print("No")
"""
FFTFFTFFFFTFFFFTFFTFFTFFFFTFFFFTFFTFF
2 2

FFFFFF
2 2
"""

### FIXED CODE ###

#import numpy as np
import math
import sys
import itertools
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
x,y = IL()
N = len(s)

xlist = []
ylist = []

f = 0
cnt = 0
for i in range(N):
  if s[i] == "F":
    cnt += 1
  elif s[i] == "T":
    if f == 0:
      xlist.append(cnt)
      f = 1
    else:
      ylist.append(cnt)
      f = 0
    cnt = 0
else:
  if f == 0:
    xlist.append(cnt)
  else:
    ylist.append(cnt)

x -= xlist.pop(0)
Xsum = sum(xlist)
Ysum = sum(ylist)

if (Xsum-x)%2 != 0:
  print("No")
  exit()
else:
  Xnum = (Xsum-abs(x))//2
if (Ysum-y)%2 != 0:
  print("No")
  exit()
else:
  Ynum = (Ysum-abs(y))//2

#print(Xnum,Ynum)

XDP = [[0]*(abs(Xnum)+1) for _ in range(len(xlist)+1)]
YDP = [[0]*(abs(Ynum)+1) for _ in range(len(ylist)+1)]

XDP[0][0] = 1
YDP[0][0] = 1

for i in range(1,len(xlist)+1):
  for j in range(Xnum+1):
    if XDP[i-1][j] == 1:
      XDP[i][j] = 1
      if j+xlist[i-1] < Xnum+1:
        XDP[i][j+xlist[i-1]] = 1
#print(Xnum)
#print(xlist)
#print(XDP)

for i in range(1,len(ylist)+1):
  for j in range(Ynum+1):
    if YDP[i-1][j] == 1:
      YDP[i][j] = 1
      if j+ylist[i-1] < Ynum+1:
        YDP[i][j+ylist[i-1]] = 1
#print(Ynum)
#print(ylist)
#print(YDP)

if XDP[-1][-1] == 1 and YDP[-1][-1] == 1:
  print("Yes")
else:
  print("No")
S = input()

def rec(s):
    leng = len(s)
    if leng==0:
        print('YES')
    else:
        if s[0:5]=="dream":
            if leng==5:
                rec(s[5:])
            else:
                if s[5:7]=="er":
                    if s[5:10]=="erase":
                        if s[10]=="r":
                            rec(s[11:])
                        else:
                            rec(s[10:])
                    else:
                        rec(s[7:])
                else:
                    rec(s[5:])
        elif s[0:5]=="erase":
            if leng==5:
                rec(s[5:])
            else:
                if s[5]=="r":
                    rec(s[6:])
                else:
                    rec(s[5:])
        else:
            print('NO')
rec(S)

### FIXED CODE ###

S = input()
S = S[::-1]
l = ['dream','dreamer','erase','eraser']
L = []
pos = 0
f=True

for i in l:
    L.append(i[::-1])

while pos < len(S):
    no_match = True
    for candidate in L:
        if S[pos:pos+len(candidate)]==candidate:
            pos+=len(candidate)
            no_match =False
            break
    if no_match:
        f =False
        break


if f:
    print('YES')
else:
    print('NO')
n, q = map(int,input().split())
cnt = [0] * (n+1)
import sys
sys.setrecursionlimit(10**6)
import numpy as np
tree = np.zeros((n+1, n+1))
child = [0] * (n+1)
for i in range(n-1):
    a, b = map(int,input().split())
    tree[a][b] = 1
    tree[b][a] = 1
def dfs(i):
    global child
    child[i] = []
    if np.all(tree[i]):
        return
    for j in range(n+1):
        if tree[i][j] == 1:
            tree[j][i] = 0
            child[i].append(j)
            dfs(j)
    return

dfs(1)
print(child)
for _ in range(q):
    p,x = map(int,input().split())
    cnt[p] += x
def plus(c):
    global cnt
    if child[c] == []:
        return
    for target in child[c]:
        cnt[target] += cnt[c]
        plus(target)
    return
plus(1)
print(*cnt[1:])

### FIXED CODE ###

n, q = map(int,input().split())
cnt = [0] * (n+1)
tree = [[] for _ in range(n+1)]
seen = [0] * (n+1)
todo = [1]
for i in range(n-1):
    a, b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)
for _ in range(q):
    p,x = map(int,input().split())
    cnt[p] += x

while todo != []:
    i = todo.pop()
    seen[i] = 1
    for j in tree[i]:
        if seen[j] == 0:
            todo.append(j)
            cnt[j] += cnt[i]
print(*cnt[1:])
N, K = map(int,input().split())
listMap = [int(i) for i in input().split()]
minMin = float("inf")
ans = 0
minLR = ""
# 正の数 or 負の数 onlyなら別処理
if listMap[0] >= 0 or listMap[-1] <= 0:
    sorted(listMap)
    ans = abs(listMap[K - 1])

else:
    for j in range(N - K):
        L = j
        R = j + K - 1
        if listMap[L] <= 0 <= listMap[R]:
            sumLR = abs(listMap[L] - listMap[R])
            if sumLR < minMin:
                minMin = sumLR
                ans = L

    # 距離を確認
    if -listMap[L] < listMap[R]:
        ans = -listMap[L] * 2 + listMap[R]
    else:
        ans = listMap[R] * 2 + -listMap[L]

print(ans)

### FIXED CODE ###

N, K = map(int,input().split())
listMap = [int(i) for i in input().split()]
minMin = float("inf")

if N == 1:
    minMin = listMap[0]

for j in range(N - (K - 1)):
    L = j
    R = j + (K - 1)
    sumL = abs(listMap[L]) + abs(listMap[L] - listMap[R])
    sumR = abs(listMap[R]) + abs(listMap[R] - listMap[L])
    sum = min(sumL, sumR)
    if sum < minMin:
        minMin = sum

print(minMin)
n=int(input())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        exit()
    else:
        continue
print(ans)

### FIXED CODE ###

import sys
n=int(input())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
  sys.exit()
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        sys.exit()
    else:
        continue
    
  if ans>1000000000000000000:
      print(-1)
  else:
      print(ans)
import itertools

import numpy as np

H, W, M = map(int, input().split())
HW = [list(map(int, input().split())) for _ in range(M)]
F = np.zeros([H, W], dtype=np.int64)

for h, w in HW:
    F[h - 1, w - 1] = 1

print("h")
"""
# 各方向の和を計算
A = np.sum(F, axis=0)
B = np.sum(F, axis=1)

maxA = np.max(A)
maxB = np.max(B)

# 最大値を取るindex
ind_A = np.arange(W)[A == maxA]
ind_B = np.arange(H)[B == maxB]

cnt = 0
ans = maxA + maxB
for h, w in itertools.product(ind_B, ind_A):
    if F[h, w] == 0:
        break

    cnt += 1
    if cnt == M:
        ans -= 1
        break
else:
    ans -= 1
print(ans)
"""


### FIXED CODE ###

import itertools

import numpy as np


def main():
    H, W, M = map(int, input().split())
    HW = [list(map(int, input().split())) for _ in range(M)]

    A = np.zeros(H, dtype=np.int64)
    B = np.zeros(W, dtype=np.int64)

    for h, w in HW:
        A[h - 1] += 1
        B[w - 1] += 1

    maxA = np.max(A)
    maxB = np.max(B)

    # 最大値を取るindex
    ind_A = np.arange(H)[A == maxA]
    ind_B = np.arange(W)[B == maxB]

    # 解の候補の数
    nn = len(ind_A) * len(ind_B)

    # Mより候補の数のほうが多いとok
    # 少ないときはM以下なので可算
    ans = maxA + maxB

    if nn <= M:
        for h, w in HW:
            if A[h - 1] == maxA and B[w - 1] == maxB:
                nn -= 1

    print(ans if nn else ans - 1)


main()
import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break

### FIXED CODE ###

N = int(input())
if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input(''))
    B = int(input(''))
    print(A + B)
x,y=map(int,input().split())
if x*2>y:
    print('No')
else:
  if y%2==1 :
    print('No')
else:
  if x*4<y :
    print('No')
else:
    print('Yes')

### FIXED CODE ###

x,y=map(int,input().split())
if x*2>y:
    print('No')
else:
  if y%2==1 :
    print('No')
  else:
    if x*4<y :
      print('No')
    else:
      print('Yes')