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

#e
H,W,M = map(int,input().split())
h = [None]*M
w = [None]*M

for i in range(M):
    a,b = map(int,input().split())
    h[i],w[i] = a-1,b-1

exist = [[False]*W for _ in range(H)]
for i in range(M):
    exist[h[i]][w[i]]=True

from collections import Counter
ch = Counter(h)
cw = Counter(w)
#print( max(ch[x]+cw[y]-exist[x][y] for x in range(H) for y in range(W) ))

x_max=max(ch.values())
cand_x_max1 = [x for x in range(H) if ch[x]==x_max]
cand_x_max2 = [x for x in range(H) if ch[x]==x_max-1]

y_max=max(cw.values())
cand_y_max1 = [y for y in range(W) if cw[y]==y_max]
cand_y_max2 = [y for y in range(W) if cw[y]==y_max-1]

from itertools import product
found=False
for x, y in product(cand_x_max1,cand_y_max1):
    if not exist[x][y]:
        found=True
        break
if found:
    print(x_max+y_max)
else:
    print(x_max+y_max-1)
    
        

### FIXED CODE ###

#e
H,W,M = map(int,input().split())
h = [None]*M
w = [None]*M
for i in range(M):
    a,b = map(int,input().split())
    h[i],w[i] = a-1,b-1


from collections import Counter
ch = Counter(h)
cw = Counter(w)

x_max=max(ch.values())
cand_x_max = [x for x in range(H) if ch[x]==x_max]

y_max=max(cw.values())
cand_y_max = [y for y in range(W) if cw[y]==y_max]

    
cnt=0
for i in range(M):
    if ch[h[i]]==x_max and cw[w[i]]==y_max:
        cnt+=1
if cnt<len(cand_x_max)*len(cand_y_max):
    print(x_max+y_max)
else:
    print(x_max+y_max-1)
### BUGGY CODE ###

N = int(input())
S = input()

def z_algo(s):
    """
    param s:str
    return list of int with length len(s)
    """
    # initialization
    n=len(s)
    z=[0]*n
    z[0]=n
    # construct
    L,R=0,0
    for i in range(1,n):
        if i>R: # 過去の結果が全く使えない
            L=R=i
            while(R<n and s[R-L]==s[R]): R+=1
            z[i]=R-L
            R-=1 # 0-indexedでiと比較するため
        elif z[i-L]<R-i+1:
            z[i]=z[i-L]
        else:
            L=i
            R+=1 # Rまでは確定しているので、R+1から確認
            while(R<n and s[R-L]==s[R]): R+=1
            z[i]=R-L
            R-=1
    return z

ans = 0
for i in range(N):
    z = z_algo(S[i:])
    z = z[(len(z)+1)//2:]
    if z:
        max_z = max(z)
        ans = max(ans, max_z)
print(ans)

### FIXED CODE ###

def resolve():
    import sys
    input=sys.stdin.readline
    N = int(input().rstrip())
    S = input().rstrip()

    def z_algo(s):
        """
        param s:str
        return list of int with length len(s)
        """
        # initialization
        n=len(s)
        z=[0]*n
        z[0]=n
        # construct
        L,R=0,0
        for i in range(1,n):
            if i>R: # 過去の結果が全く使えない
                L=R=i
                while(R<n and s[R-L]==s[R]): R+=1
                z[i]=R-L
                R-=1 # 0-indexedでiと比較するため
            elif z[i-L]<R-i+1:
                z[i]=z[i-L]
            else:
                L=i
                R+=1 # Rまでは確定しているので、R+1から確認
                while(R<n and s[R-L]==s[R]): R+=1
                z[i]=R-L
                R-=1
        return z

    ans = 0
    for i in range(N-1):
        z = z_algo(S[i:])
        for j, _z in enumerate(z):
            ans=max(ans,min(j,z[j]))
    print(ans)

resolve()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))

def main():
    ans = N
    for i, ai in enumerate(A):
        for aj in A[:i]+A[i+1:]:
            if ai % aj == 0:
                ans -= 1
                break
    print(ans)

main()


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)
counter = [0]*(maxA+1)
for ai in A:
    for m in range(ai, maxA+1, ai):
        counter[m] += 1
ans = 0
for ai in A:
    ans += (counter[ai] == 1)
print(ans)
### BUGGY CODE ###

def main():
    n = int(input())
    l1 = l2 = l3 = 0
    l = [int(i) for i in input().split()]
    for i in l:
        if i == 1:
            l1 += 1
        elif i == 2:
            l2 += 1
        else:
            l3 += 1
    a = l2+l3
    dp = [[[0]*(l3+1) for i in range(a+1)] for j in range(n+1)]

    for i in range(1,n+1):
        for j in range(min(i,a)+1):
            for k in range(min(j,l3)+1):
                s = i-j
                t = j-k
                count = n/(s+t+k)
                if s > 0:
                    count += dp[s-1][t][k]*(s/(s+t+k))     
                if t > 0 :
                    count += dp[s+1][t-1][k]*(t/(s+t+k))
                if k > 0 :
                    count += dp[s][t+1][k-1]*(k/(s+t+k))

                dp[s][t][k] = count

    print(dp[l1][l2][l3])
if __name__ == "__main__":
    main()



### FIXED CODE ###

N=int(input())
A=[int(i) for i in input().split()]
I,J,K=0,0,0
for a in A:
    if a==1:
        I+=1
    if a==2:
        J+=1
    if a==3:
        K+=1
L=I+J+K
M=J+K
dp=[[[0.0]*(K+1) for i in range(M+1)] for i in range(L+1)]
for n in range(1,L+1):#n=i+j+k
    for m in range(min(n,M)+1):#m=j+k
        for k in range(min(m,K)+1):
            j=m-k
            i=n-m
            #print(i,j,k)
            ret=N/(i+j+k)
            if i>0:
                ret+=dp[i-1][j][k]*(i/(i+j+k))
            if j>0:
                ret+=dp[i+1][j-1][k]*(j/(i+j+k))
            if k>0:
                ret+=dp[i][j+1][k-1]*(k/(i+j+k))
            dp[i][j][k]=ret
print(dp[I][J][K])
### BUGGY CODE ###

import sys
input=sys.stdin.readline


class UnionFind(object):
    def __init__(self, n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self, a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def getsize(self, a):
        return self.size[self.find(a)]
    def unite(self, a, b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self, a, b):
        return self.find(a)==self.find(b)


def solve():
    N, M, K = map(int, input().split())

    d = {i:set() for i in range(1, N+1)}
    block = {i:set() for i in range(1, N+1)}
    candidate = {i:set() for i in range(1, N+1)}

    uft = UnionFind(N)

    for _ in range(M):
        A, B = map(int, input().split())
        d[A].add(B)
        d[B].add(A)
        uft.unite(A, B)

    for _ in range(K):
        C, D = map(int, input().split())
        block[C].add(D)
        block[D].add(C)

    for i in range(1, N+1):
        cd = set(range(i+1, N+1))-d[i]-block[i]
        for j in cd:
            if uft.isunited(i, j):
                candidate[i].add(j)
                candidate[j].add(i)

    print(*map(len, candidate.values()))


if __name__ == "__main__":
    solve()


### FIXED CODE ###

import sys
input=sys.stdin.readline


class UnionFind(object):
    def __init__(self, n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self, a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def getsize(self, a):
        return self.size[self.find(a)]
    def unite(self, a, b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self, a, b):
        return self.find(a)==self.find(b)


def solve():
    N, M, K = map(int, input().split())
    uft = UnionFind(N)
    d = {i:set() for i in range(1, N+1)}
    e = {i:0 for i in range(1, N+1)}
    f = {i:0 for i in range(1, N+1)}

    for _ in range(M):
        A, B = map(int, input().split())
        d[A].add(B)
        d[B].add(A)
        f[A] += 1
        f[B] += 1
        uft.unite(A, B)

    for _ in range(K):
        C, D = map(int, input().split())
        if uft.isunited(C, D):
            if not D in d[C]:
                e[C] += 1
            if not C in d[D]:
                e[D] += 1

    print(*(uft.getsize(i)-e[i]-f[i]-1 for i in range(1, N+1)))


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

# -*- coding: utf-8 -*-
import re
# input
n, q = map(int, input().split())
a = [0 for i in range(n)]
s = input()
for m in re.finditer('AC', s):
    a[m.start()] = 1
for i in range(q):
    l, r = map(int, input().split())
    output = 0
    for j in range(l-1, r-1):
        output += a[j]
    print(output)

### FIXED CODE ###

# input
n, q = map(int, input().split())
a = [0 for i in range(n+1)]
s = input()
for i in range(n):
    a[i+1] = a[i] + (1 if s[i:i+2] == 'AC' else 0)
# for m in re.finditer('AC', s):
#    a[m.start()] = 1
for i in range(q):
    l, r = map(int, input().split())
    print(a[r-1]-a[l-1])
### BUGGY CODE ###

# Author: cr4zjh0bp
# Created: Fri Mar 20 22:48:43 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import deque

h, w = na()
m = nsn(h)

def bfs():
    q = deque()
    al = 0
    f = False
    if m[0][0] == '#':
        al += 1
        f = True
    q.append((0, 0, al, f))
    d = [[inf] * w for _ in range(h)]
    res = inf
    dx, dy = [0, 1], [1, 0]
    while len(q):
        p = q.popleft()
        x, y, l, flag = p
        for i in range(2):
            nx, ny = x + dx[i], y + dy[i]
            if nx >= 0 and nx < w and ny >= 0 and ny < h:
                nl = l
                if m[ny][nx] == '#':
                    if not flag:
                        nl += 1
                    q.append((nx, ny, nl, True))
                else:
                    q.append((nx, ny, nl, False))
                d[ny][nx] = min(d[ny][nx], nl)
    return d[h - 1][w - 1]

print(bfs())

### FIXED CODE ###

# Author: cr4zjh0bp
# Created: Fri Mar 20 22:48:43 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import deque

h, w = na()
m = nsn(h)

def bfs():
    q = deque()
    al = 0
    f = False
    if m[0][0] == '#':
        al += 1
        f = True
    q.append((0, 0, al, f))
    d = [[inf] * w for _ in range(h)]
    res = inf
    dx, dy = [0, 1], [1, 0]
    while len(q):
        p = q.popleft()
        x, y, l, flag = p
        for i in range(2):
            nx, ny = x + dx[i], y + dy[i]
            nl = l
            if nx >= 0 and nx < w and ny >= 0 and ny < h and d[ny][nx] > nl:
                if m[ny][nx] == '#':
                    if not flag:
                        nl += 1
                    q.append((nx, ny, nl, True))
                else:
                    q.append((nx, ny, nl, False))
                d[ny][nx] = min(d[ny][nx], nl)
    return d[h - 1][w - 1]

print(bfs())
### BUGGY CODE ###

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

count = {}
for a in A:
    if count.get(a):
        count[a] += 1
    else:
        count[a] = 1

q = int(input())
B = []
C = []
for i in range(q):
    b, c = list(map(int, input().split()))
    B.append(b)
    C.append(c)
for i in range(q):
    b = B[i]
    c = C[i]
    if count.get(b):
        count[c] = count.get(c, 0) + count.pop(b)
    sum = 0
    for key, value in count.items():
        sum += key * value
    print(sum)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
num = [0] * (10 ** 5 + 1)

for a in A:
    num[a] += 1
_sum = sum(A)

result = []
q = int(input())
for i in range(q):
    b, c = list(map(int, input().split()))
    _sum += (c - b) * num[b]
    num[c] += num[b]
    num[b] = 0
    result.append(str(_sum))
print('\n'.join(result))
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

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

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

n = I()
a = LI()
l = 1
for i in a:
    l = lcm(l,i)

ans = 0
for i in a:
    ans += l*pow(i,mod-2,mod)
    ans %= mod
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

n = I()
a = LI()
l = lcm(a)
ans = 0
l %= mod
for i in a:
    ans += l*pow(i,mod-2,mod)
    ans %= mod
print(ans)
### BUGGY CODE ###

a, b, k = map(int, input().split())
numalllist = [num for num in range(a, b + 1)]
if 2 * k >= len(numalllist) :
    for i in numalllist :
        print(i)
else :
    anslist = numalllist[:k] + numalllist[-k:]
    for i in anslist :
        print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
if 2 * k >= b - a + 1 : 
    i = a
    while i <= b :
        print(i)
        i += 1
else :
    i = a
    while i <= a + k - 1 :
        print(i)
        i += 1
    i = b - k + 1
    while i <= b :
        print(i)
        i += 1
### BUGGY CODE ###

H,W = map(int,input().split())
maze = [list(input()) for j in range(H)]

def bfs(h,w):
  checked = [[False for i in range(W)] for j in range(H)]
  q = [(h,w,0)] if maze[h][w]=="." else []
  g_n = 0
  while q:
    h_,w_,n = q.pop(0)
    checked[h_][w_] = True
    g_n = max(n, g_n)
    for i,j in zip([0,0,-1,1],[-1,1,0,0]):
      if (0<=h_+i<H) and (0<=w_+j<W):
        if checked[h_+i][w_+j]: continue
        if maze[h_+i][w_+j]==".": q.append((h_+i,w_+j,n+1))
  return g_n

n = 0
for i in range(H):
  for j in range(W):
    n = max(n, bfs(i,j))
print(n)

### FIXED CODE ###

H,W = map(int,input().split())
maze = [list(input()) for j in range(H)]

def bfs(h,w):
  checked = [[False for i in range(W)] for j in range(H)]
  q = [(h,w,0)] if maze[h][w]=="." else []
  checked[h][w] = True
  g_n = 0
  while q:
    h_,w_,n = q.pop(0)
    g_n = max(n, g_n)
    for i,j in zip([0,0,-1,1],[-1,1,0,0]):
      if (0<=h_+i<H) and (0<=w_+j<W):
        if checked[h_+i][w_+j]: continue
        checked[h_+i][w_+j] = True
        if maze[h_+i][w_+j]==".": q.append((h_+i,w_+j,n+1))
  return g_n

n = 0
for i in range(H):
  for j in range(W):
    n = max(n, bfs(i,j))
print(n)
### BUGGY CODE ###

n=int(input())
an = list(map(int, input().split()))
dan=0
for i in range(n-1):
  while an[i]>an[i+1]:
    an[i+1]=an[i+1]+1
    #print(an[i])
    dan=dan+1
print(dan)

### FIXED CODE ###

n=int(input())
an = list(map(int, input().split()))
dan=0
for i in range(n-1):
  if an[i]>an[i+1]:
    dan=dan+(an[i]-an[i+1])
    an[i+1]=an[i]
    
print(dan)
### BUGGY CODE ###

import itertools
ans=0
n=int(input())
l=list(map(int,input().split()))
for a,s,d in itertools.combinations(l, 3):
  if abs(a-s)<d<a+s:ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
from bisect import bisect_left as bl,bisect_right as br
for i in range(n):
    for j in range(i+1,n):
        a,s=l[i],l[j]
        ans+=-1-int(s<2*a)+bl(l,a+s)-br(l,s-a)
print(ans//3)
### BUGGY CODE ###

n=int(input())
s=input()
cnt=0

a=[]
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      c=s[i]+s[j]+s[k]
      if c not in a:
        a.append(c)
        cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
s=input()
cnt=0
for m in range(1000):
  m=str(m).zfill(3)
  j=0
  for i in m:
    if i not in s[j:]:break
    j+=s[j:].index(i)+1
  else:cnt+=1
print(cnt)
### BUGGY CODE ###

# python3だとTLE,pypy3だとAC
def main():
    s = input()
    t = input()
    dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]
    for i, cs in enumerate(s, start=1):
        for j, ct in enumerate(t, start=1):
            if cs == ct:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
    ans = ""
    i = len(s)
    j = len(t)
    while i > 0 and j > 0:
        if i > 0 and j > 0:
            if dp[i-1][j] > dp[i][j-1]:
                i -= 1
            elif dp[i-1][j] < dp[i][j-1]:
                j -= 1
            else:
                if dp[i-1][j-1]+1 == dp[i][j]:
                    i -= 1
                    j -= 1
                    ans += s[i]
                else:
                    i -= 1

    print(ans[::-1])


if __name__ == "__main__":
    main()


### FIXED CODE ###

# python3だとTLE,pypy3だとAC
def main():
    s = input()
    t = input()
    dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]
    for i, cs in enumerate(s, start=1):
        for j, ct in enumerate(t, start=1):
            if cs == ct:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
    ans = ""
    i = len(s)
    j = len(t)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            i -= 1
            j -= 1
            ans = s[i] + ans

    print(ans)


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

#!/usr/bin/env python3
 
import sys
# 以下を記述しないとTLEになる, 何故？
import heapq
from collections import defaultdict
# ---- ここまで -----------------------
 
S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()
 
ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1
 
print(ans)

### FIXED CODE ###

import bisect
s = input().rstrip()
t = input().rstrip()

a_ord = ord("a")
ch_place = [[] for _ in range(26)]
for i, ch in enumerate(s):
    ch_place[ord(ch) - a_ord].append(i)

# print(ch_place)

count = 0
idx = -1 
for ch in t:
    ch_num = ord(ch) - a_ord
    if len(ch_place[ch_num]) == 0:
        print(-1)
        exit()
    place = bisect.bisect_right(ch_place[ch_num], idx)
    # print(ch_place[ch_num], idx, place)
    if place == len(ch_place[ch_num]):
        idx = ch_place[ch_num][0]
        count += 1
    else:
        idx = ch_place[ch_num][place]

# print(count, idx)
print(count * len(s) + idx + 1)
### BUGGY CODE ###

def even_bit_maker(number_length):
    bit = 0
    for i in range(number_length):
        if i % 2 == 0:
            bit += 2 ** i
    return bit


def odd_bit_maker(number_length):
    bit = 0
    for i in range(number_length):
        if i % 2 == 1:
            bit += 2 ** i
    return bit


if __name__ == '__main__':
    init_tile = input()
    init_tile_bit = int(init_tile, 2)
    tile_len = len(init_tile)
    even_bit = init_tile_bit ^ even_bit_maker(tile_len)
    odd_bit = init_tile_bit ^ odd_bit_maker(tile_len)
    even_change_count = bin(even_bit).count('1')
    odd_change_count = bin(odd_bit).count('1')
    print(min(even_change_count, odd_change_count))


### FIXED CODE ###

def even_bit_maker(number_length):
    bit = ['0'] * number_length
    for i in range(number_length):
        if i % 2 == 0:
            bit[i] = '1'
    return int(''.join(bit), 2)


def odd_bit_maker(number_length):
    bit = ['0'] * number_length
    for i in range(number_length):
        if i % 2 == 1:
            bit[i] = '1'
    return int(''.join(bit), 2)


if __name__ == '__main__':
    init_tile = input()
    init_tile_bit = int(init_tile, 2)
    tile_len = len(init_tile)
    even_bit = init_tile_bit ^ even_bit_maker(tile_len)
    odd_bit = init_tile_bit ^ odd_bit_maker(tile_len)
    even_change_count = bin(even_bit).count('1')
    odd_change_count = bin(odd_bit).count('1')
    print(min(even_change_count, odd_change_count))
### BUGGY CODE ###

H,W=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
B=[list(map(int,input().split())) for i in range(H)]
m=80*(H+W)
d=[[[0]*m for i in range(W+1)] for j in range(H+1)]
d[1][1][A[0][0]-B[0][0]]=d[1][1][B[0][0]-A[0][0]]=1
for h in range(H):
    for w in range(W):
        x=A[h][w]-B[h][w]
        for y in range(m):
            if d[h][w+1][y] or d[h+1][w][y]:
                d[h+1][w+1][(y+x)%m]=d[h+1][w+1][(y-x)%m]=1
for i in range(m):
    if d[H][W][i] or d[H][W][-i]:
        print(i)
        exit()

### FIXED CODE ###

H,W=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
B=[list(map(int,input().split())) for i in range(H)]
d=[[0]*W for j in range(H)]
m=80*(H+W)
d[0][0]=1<<m
for h in range(H):
    for w in range(W):
        x=abs(A[h][w]-B[h][w])
        if h>0:
            d[h][w]|=d[h-1][w]
        if w>0:
            d[h][w]|=d[h][w-1]
        d[h][w]=d[h][w]<<x|d[h][w]>>x
x,y=1<<m,1<<m
for i in range(99):
    if d[H-1][W-1]&x or d[H-1][W-1]&y:
        print(i)
        exit()
    x<<=1
    y>>=1
### BUGGY CODE ###

N, M = list(map(int, input().split()))
first_dest_list = list()
pair_list = list()

for _ in range(M):
    a, b = list(map(int, input().split()))

    if a == 1:
        first_dest_list.append(b)
    elif b == 1:
        first_dest_list.append(a)

    pair_list.append((a, b))


len_first_dest = len(first_dest_list)
result = 'IMPOSSIBLE'
for first_dest in first_dest_list:
    for i in range(M):
        if first_dest in pair_list[i] and N in pair_list[i]:
            result = 'POSSIBLE'
            break
    if result == 'POSSIBLE':
        break

print(result)


### FIXED CODE ###

N, M = list(map(int, input().split()))
dest_list_1 = list()
dest_list_2 = list()

for _ in range(M):
    a, b = list(map(int, input().split()))

    if a == 1:
        dest_list_1.append(b)
    elif b == 1:
        dest_list_1.append(a)
    elif a == N:
        dest_list_2.append(b)
    elif b == N:
        dest_list_2.append(a)

len_dest_1 = len(dest_list_1)
len_dest_2 = len(dest_list_2)

if len(set(dest_list_1 + dest_list_2)) == len_dest_1 + len_dest_2:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')