Harryxun/stf_run huggingface dataset:
import math
print(math.factorial(n)%(10**9+7))

### FIXED CODE ###

import math
n=int(input())
print(math.factorial(n)%(10**9+7))
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

data = []
input_data = input().split()
data = [int(n) for n in input_data]
data_exp = []
for d in data:
    data_exp.append(1 + (d-1)/2)

ans = 0
for i in range(0, n-k+1, 1):
    exp_val = 0
    for j in range(k):
        exp_val += data_exp[i+k]
    ans = max(ans, exp_val)

print(ans)




### FIXED CODE ###

import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import heapq
import collections
import itertools
sys.setrecursionlimit(100001)

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

data = []
input_data = input().split()
data = [int(n) for n in input_data]

data_exp = [0]
for i in range(n):
    data_exp.append(data_exp[i] + 1 + (data[i]-1)/2)

ans = 0
for i in range(n-k+1):
    tmp_ans = data_exp[i+k] - data_exp[i]
    ans = max(ans, tmp_ans)

print(ans)
s=input()
X,Y=map(int,input().split())
def solve(a,G):
    dp=[[0]*16001 for _ in range(len(x))]
    dp[0][a[0]]=1

    for i in range(1,len(a)):

        for j in range(-8001,8001):
            dp[i][j-a[i]]+=dp[i-1][j]
            dp[i][j+a[i]]+=dp[i-1][j]
            #print(dp)
            if dp[i][G]>=1:
                return True
    return False

x=[]
y=[0]
flg=1
cnt=0
if s[0]=="T":
    x.append(0)
for i in range(len(s)):
    if s[i]=="F":
        cnt+=1
    else:
        if flg==1:
            x.append(cnt)
            flg*= -1
            cnt=0
        else:
            y.append(cnt)
            flg*= -1
            cnt=0
if flg==1:
    x.append(cnt)
else:
    y.append(cnt)
#print(x)
#print(y)
if solve(x,X) and solve(y,Y):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

s=input()
X,Y=map(int,input().split())
from collections import defaultdict
def solve(da,dp,G):
    for i in range(len(da)):
        tmp=set()
        for j in dp:
            tmp.add(j-da[i])
            tmp.add(j+da[i])
        dp=tmp
    if G in dp:
        return True
    else:
        return False
    """amax=0
    for i in a:
        amax+=abs(i)
    if amax==0:
        if G==0:
            return True
        else:
            return False
    if a[0]==G:
        return True
    dp=[[0]*2*amax for _ in range(3)]
    dp[0][a[0]]=1
    for i in range(1,len(a)):
        p=a[i]
        for j in range(-amax,amax):
            dp[i%3][j-p]+=dp[(i-1)%3][j]
            dp[i%3][j+p]+=dp[(i-1)%3][j]
            #print(dp)
        if dp[i%3][G]>=1:
            return True
    return False"""
    """#print(a)
    dp=set()
    dp.add(a[0])
    dp2=set()
    for i in range(1,len(a)):
        for j in dp:
            dp2.add(j-a[i])
            dp2.add(j+a[i])
        dp=copy.deepcopy(dp2)
    #print(dp)
    if G in dp:
        return True
    return False"""

d=[len(x) for x in s.split("T")]

dx=d[2::2]
dy=d[1::2]

if solve(dx,{d[0]},X) and solve(dy,{0},Y):
    print("Yes")
else:
    print("No")
A,P=map(int,input().split())
return (A*3+P)//2


### FIXED CODE ###

A,P=map(int,input().split())
print((A*3+P)//2)
N = int(input())
A = []
for i in len(N):
    A.append(int(input()))
print(len(set(A)))

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
print(len(set(A)))
w=input()
w1=input()
num=len(w)
num1=len(w1)
if num<num1:
  b=False
for i in range(num-num1+1):
  b=True
  for j in range(i,i+num1):
    if w[i+j]=="?" or w[i+j]==w1[j]:
      pass
    else:
      b=False
  if b:
      start=i
      break
if not b:
  print("UNRESTORABLE")
else:
  word=""
  if start!=0:
    for i in range(start):
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
    for i in range(start,num):
      word+=w1[i-start]
  else:
    word+=w1
    for i in range(num1,num):
      if w[num]=="?":
        word+="a"
      else:
        word+=w[num]
  print(word)

### FIXED CODE ###

w=input()
w1=input()
num=len(w)
num1=len(w1)
start=-1
if num<num1:
  b1=False
for i in range(num-num1+1):
  b=True
  for j in range(num1):
    if w[i+j]=="?" or w[i+j]==w1[j]:
      pass
    else:
      b=False
  if b:
      start=i
if start==-1:
  print("UNRESTORABLE")
else:
  word=""
  for i in range(num):
    if i<start:
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
    elif start<=i and i<=start+num1-1:
      word+=w1[i-start]
    else:
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
  print(word)
import sys
input = sys.stdin.readline


def pow_mod(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K*x

#main関数
def main():
    """"ここに今までのコード"""

    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9+7

    plist = [0]*1000
    lcm = 1
    nokori=set()
    for a in A:
        for j in range(2, 1001):
            count_j=0
            while a % j == 0:
                count_j += 1
                a //= j
            plist[j-1]=max(plist[j-1],count_j)
        nokori |= {a}
    for x in nokori:
        lcm *= x
        lcm %= mod

    for i in range(1000):
        lcm *= pow_mod(i+1, plist[i], mod)
        lcm %= mod
    
    ans = 0

    for a in A:
        ans += lcm * pow_mod(a, mod-2, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from fractions import gcd
import sys 
input = sys.stdin.readline

def pow_mod(x,n):
    if n==0:
        return 1
    
    K = 1
    while n>1:
        if n%2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K*x

mod=10**9+7
N = int(input())
A = list(map(int,input().split()))

if N==1:
    print(1)
    exit()

Gcd = gcd(A[0],A[1])
ans = (A[0]//Gcd+A[1]//Gcd)%mod
temp = A[0]//Gcd

for i in range(1,N-1):
    #Gcd = lcm(A[i],A[i+1])
    Gcd = gcd(A[i],A[i+1])
    #temp2 = Gcd//A[i]
    temp2 = A[i+1]//Gcd
    #Gcd2 = lcm(temp,temp2)
    Gcd2 = gcd(temp,temp2)

    #a = Gcd2//temp
    a = temp2//Gcd2
    #b = Gcd2//temp2
    b = temp//Gcd2

    temp = A[i]//Gcd*b

    a %= mod
    b %= mod
    ans *= a
    ans %= mod


    Gcd %= mod #注意
    c = A[i]
    c %= mod
    d = c*pow_mod(Gcd,mod-2)
    #d = Gcd//c
    d %= mod


    e = b*d%mod
    ans += e
    #ans += Gcd//A[i+1]*b
    ans %= mod


print(ans)
n=int(input())
mat=[[]*n for _ in range(n)]
group=[0]*n
group[0]=1
for i in range(n-1):
    u, v, w = map(int, input().split())
    mat[u-1].append((v-1, w))
    mat[v-1].append((u-1, w))
def C(kw, p, l):
    global group
    k, w = kw
    if w%2==1:
        p*=-1
    group[k]=p
    for kwi in mat[k]:
        if kwi[0]!=l:
            C(kwi, p, k)
for kwi in mat[0]:
    C(kwi, 1, 0)
for gi in group:
    if gi>0:
        print(1)
    else:
        print(0)

### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)
n=int(input())
mat=[[] for i in range(n)]
group=[0]*n
group[0]=1
for i in range(n-1):
    u, v, w = map(int, input().split())
    mat[u-1].append((v-1, w))
    mat[v-1].append((u-1, w))
def C(kw, p, l):
    global group
    k, w = kw
    if w%2==1:
        p*=-1
    group[k]=p
    for kwi in mat[k]:
        if kwi[0]!=l:
            C(kwi, p, k)
for kwi in mat[0]:
    C(kwi, 1, 0)
for gi in group:
    if gi>0:
        print(1)
    else:
        print(0)
a = input()
b = input()
c = input()

if (a == b and b == c):
    print('No')
elif(a != c and a != b and b != c):
    print('No')
else:
    print('Yes')


### FIXED CODE ###

a, b, c = map(int, input().split()) 


if (a == b and b == c):
    print('No')
elif(a != c and a != b and b != c):
    print('No')
else:
    print('Yes')
n,m = map(int,input().split())
point = 1
now = [i for i in range(n)]
exist = [1 for i in range(n)]
for turn in range(1,m+1):
    cnt = 0
    while True:
        if exist[cnt]:
            if exist[(now[cnt]+turn)%n]:
                print(cnt+1,(cnt+turn)%n+1)
                exist[cnt] = 0
                exist[(now[cnt]+turn)%n] = 0
                break
        cnt += 1

### FIXED CODE ###

n,m = map(int,input().split())
if n % 2 == 1:
    ans = [[1+i,n-i] for i in range(n//2)]
else:
    ans = [[1+i,n-i] for i in range(n//4)]+[[n//2+1+i,n//2-1-i] for i in range(n//2-n//4-1)]
for i in range(m):
    print(ans[i][0],ans[i][1])
import itertools
import numpy as np

N, M, X = map(int, input().split())
lis_all = [list(map(int, input().split())) for _ in range(N)]

lis_C = np.array(list(map(lambda x: x[0], lis_all)))
lis_A = np.array(list(map(lambda x: x[1:], lis_all)))

row_idx = []
bools = [True,False]
for boollis in itertools.product(bools, repeat=M):
    row_idx.append(list(boollis))

c_min = lis_C.sum()+100
for i in range(len(lis_idx)):
    if all(lis_A[row_idx[i]].sum(axis=0) >= X):
        c_min = min(lis_C[row_idx[1]].sum(), c_min)
if c_min > lis_C.sum():
    ans = -1
else :
    ans = c_min
print(ans)

### FIXED CODE ###

import itertools
import numpy as np

N, M, X = map(int, input().split())
lis_all = [list(map(int, input().split())) for _ in range(N)]

lis_C = np.array(list(map(lambda x: x[0], lis_all)))
lis_A = np.array(list(map(lambda x: x[1:], lis_all)))

row_idx = []
bools = [True,False]
for boollis in itertools.product(bools, repeat=N):
    row_idx.append(list(boollis))


c_min = lis_C.sum()+100
for i in range(len(row_idx)):
    if all(lis_A[row_idx[i]].sum(axis=0) >= X):
        c_min = min(lis_C[row_idx[i]].sum(), c_min)
if c_min > lis_C.sum():
    ans = -1
else :
    ans = c_min
print(ans)
import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    st=[tx-sx,ty-sy]; rst=R(st)
    F=[rwt<r,rsw<r]
    if rst==0: c=1
    elif F==[1,1]: c=1
    elif F==[1,0] or F==[0,1]: c=0
    elif F==[0,0]:
      c=0
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos((sw[0]*st[0]+sw[1]*st[1])/rsw/rst)
#      if C(a,b) and C(rst**2,rsw**2-r**2): c=0
#      else: c=1
    x.append(c)
  return all(x)

while 1:
  n=input()
  if n==0: break
  WP=I(n)
  P=I(input())
  for e in P: print ["Safe","Danger"][f(e)]

### FIXED CODE ###

import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  st=[tx-sx,ty-sy]; rst=R(st)
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    F=[rwt<r,rsw<r]
    if F==[1,0] or F==[0,1]: return 0
    elif F==[0,0]:
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4))
      if C(a,b) and C(rst**2,rsw**2-r**2): return 0
  return 1

while 1:
  n=input()
  if n==0: break
  WP=I(n)
  P=I(input())
  for e in P: print ["Safe","Danger"][f(e)]
import math
import numpy as np
a, b, h, m = input().split()
x = a**2 + b**2 -(2*a*b*cos(((m-5*h)/60)*math.pi))
x = np.sqrt(x)
print(x)

### FIXED CODE ###

import math
s = input().split()
a = int(s[0])
b = int(s[1])
h = int(s[2])
m = int(s[3])
th = 30*h + m/2
tm = 6*m
#print(j)
j = math.cos(math.radians(abs(th-tm)))
#print(j)
x = a**2 + b**2 -(2*a*b*j)
x = math.sqrt(x)
print(x)
s = input().strip()
chars = list(set(s))
chars.sort()
dic = {"a": 0,
       "b": 1,
       "c": 2,
       "d": 3,
       "e": 4,
       "f": 5,
       "g": 6,
       "h": 7,
       "i": 8,
       "j": 9,
       "k": 10,
       "l": 11,
       "m": 12,
       "n": 13,
       "o": 14,
       "p": 15,
       "q": 16,
       "r": 17,
       "s": 18,
       "t": 19,
       "u": 20,
       "v": 21,
       "w": 22,
       "x": 23,
       "y": 24,
       "z": 25
       }
swap = {v: k for k, v in dic.items()}
ans = "None"
count = 0
for c in chars:
    if dic[c] != count:
        ans = swap[count]
        break
    count += 1
if count != 25:
    print(swap[count])
else:
    print(ans)


### FIXED CODE ###

s = input().strip()
chars = list(set(s))
chars.sort()
dic = {"a": 0,
       "b": 1,
       "c": 2,
       "d": 3,
       "e": 4,
       "f": 5,
       "g": 6,
       "h": 7,
       "i": 8,
       "j": 9,
       "k": 10,
       "l": 11,
       "m": 12,
       "n": 13,
       "o": 14,
       "p": 15,
       "q": 16,
       "r": 17,
       "s": 18,
       "t": 19,
       "u": 20,
       "v": 21,
       "w": 22,
       "x": 23,
       "y": 24,
       "z": 25
       }
swap = {v: k for k, v in dic.items()}
ans = "None"
count = 0
for c in chars:
    if dic[c] != count:
        ans = swap[count]
        break
    count += 1
if count <= 25:
    print(swap[count])
else:
    print(ans)
import bisect

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

INF = float('inf')
for _ in range(q):
    x = int(input())
    if x > s[a-1]:
        sl = x - s[a-1]
        sr = INF
    elif x < s[0]:
        sl = INF
        sr = s[0] - x
    else:
        si = bisect.bisect_right(s, x)
        sl = x - s[si-1]
        sr = s[si] - x

    if x > t[a-1]:
        tl = x - t[a-1]
        tr = INF
    elif x < t[0]:
        tl = INF
        tr = t[0] - x
    else:
        ti = bisect.bisect_right(t, x)
        tl = x - t[ti-1]
        tr = t[ti] - x

    ans = min(max(sl, tl), max(sr, tr))

    ans = min(ans, sr*2+tl)
    ans = min(ans, sr+tl*2)
    ans = min(ans, sl*2+tr)
    ans = min(ans, sl+tr*2)

    print(ans)


### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

INF = float('inf')
for _ in range(q):
    x = int(input())
    if x > s[a-1]:
        sl = x - s[a-1]
        sr = INF
    elif x < s[0]:
        sl = INF
        sr = s[0] - x
    else:
        si = bisect.bisect_right(s, x)
        sl = x - s[si-1]
        sr = s[si] - x

    if x > t[b-1]:
        tl = x - t[b-1]
        tr = INF
    elif x < t[0]:
        tl = INF
        tr = t[0] - x
    else:
        ti = bisect.bisect_right(t, x)
        tl = x - t[ti-1]
        tr = t[ti] - x

    ans = min(max(sl, tl), max(sr, tr))

    ans = min(ans, sr*2+tl)
    ans = min(ans, sr+tl*2)
    ans = min(ans, sl*2+tr)
    ans = min(ans, sl+tr*2)

    print(ans)
s = input()
p = input()
????
s += s[:len(p)]
if p in s:
????????print("Yes")
else:
????????print("No")

### FIXED CODE ###

s = input()
p = input()
  
s += s[:len(p)]
if p in s:
    print("Yes")
else:
    print("No")
n = int(input())
x = []
y = []
index = []
for i in range(n):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
    index.append(i)

distance = 0
for v in itertools.permutations(index):
    for i in range(n-1):
        distance += math.sqrt((x[v[i]] - x[v[i+1]]) **
                              2 + (y[v[i]]-y[v[i+1]])**2)


print(distance/math.factorial(n))

### FIXED CODE ###

import itertools
import math

n = int(input())
x = []
y = []
index = []
for i in range(n):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
    index.append(i)

distance = 0
for v in itertools.permutations(index):
    for i in range(n-1):
        distance += math.sqrt((x[v[i]] - x[v[i+1]]) **
                              2 + (y[v[i]]-y[v[i+1]])**2)


print(distance/math.factorial(n))
def solve():
    N = int(input())
    a = [int(x) for x in input().split()]

    import collections
    count = collections.Counter(a)

    valid = {k:v for k, v in count.items() if v >= 2}

    # print(valid)

    m = sorted(valid.keys(), reverse=True)
    a, b = m[0], m[1]

    return a*b


def main():
    print(solve())


if __name__ == '__main__':
    main()

### FIXED CODE ###

def solve():
    N = int(input())
    a = [int(x) for x in input().split()]

    import collections
    count = collections.Counter(a)

    valid = {k: v for k, v in count.items() if v >= 2}

    # print(valid)

    m = sorted(valid.items(), reverse=True)

    if len(valid) == 0:
        return 0
    elif m[0][1] >= 4:
        return m[0][0] ** 2
    elif len(valid) >= 2:
        return m[0][0] * m[1][0]
    else:
        return 0


def main():
    print(solve())


if __name__ == '__main__':
    main()
N = int(input())

d = {}
for _ in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1

m = max(d.values)
l = []
for k in d:
    v = d[k]
    if v != m:
        continue
    l.append(v)

for s in sorted(l):
    print(s)


### FIXED CODE ###

N = int(input())

d1 = {}
for _ in range(N):
    S = input()
    if S in d1:
        d1[S] += 1
    else:
        d1[S] = 1

d2 = {}
for key in d1:
    value = d1[key]
    if value in d2:
        d2[value].append(key)
    else:
        d2[value] = [key]

key = sorted(d2.keys(), reverse=True)[0]
for s in sorted(d2[key]):
    print(s)
import math
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i in b[1:]:
        ans=math.gcd(ans,i)
    print(ans) 

### FIXED CODE ###

import fractions
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i in b[1:]:
        ans=fractions.gcd(ans,i)
    print(ans)
P = list(input().split())
if (P.count('5') == 2 and P.count('7') == 1):
  print('YES')
else:
  prit('NO')

### FIXED CODE ###

P = list(input().split())
if (P.count('5') == 2 and P.count('7') == 1):
  print('YES')
else:
  print('NO')
N=int(input())
A=[int(i) for i in input().split()]
B=[None for i in range(N)]
res=0
for n in range(N):
	if n%2!=0:res-=A[n]
	else:res+=A[n]
B[0]=res
ans=str(res)+" "
for i in range(1,N):
	B[i]=int((A[i-1]-(int(B[i-1])/2))*2)
	ans=str(ans)+str(B[i])+" "

print(ans)


### FIXED CODE ###

A=[int(i) for i in input().split()]
n=A[0]
a=A[1]
b=A[2]
c=n*a

if c>b:
	print(b)
else:
	print(c)
n=int(input())
a=[]

x,y,k=-1,-1,-1
n=-1
for o in range(n):
    a.append(list(map(int,input().split())))
    if a[o][2] != 0:
        n=o
for i in range(101):
    for j in range(101):
        h=a[n][2]+abs(a[n][0]-i)+abs(a[n][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()



### FIXED CODE ###

n=int(input())
xyh=[]

x,y,h=-1,-1,-1
nonzero=-1

for i in range(n):
    xyh.append(list(map(int,input().split())))
    if xyh[i][2] != 0:
        nonzero = i

for px in range(101):
    for py in range(101):
        nh = xyh[nonzero][2]+abs(xyh[nonzero][0]-px)+abs(xyh[nonzero][1]-py)
        ok = True

        for nn in range(n):
            if xyh[nn][2] > 0 and nh != xyh[nn][2]+abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py):
                ok=False
            if xyh[nn][2] == 0 and nh > abs(xyh[nn][0]-px) +abs(xyh[nn][1]-py):
                ok=False
        
        if ok:
            x,y,h = px,py,nh
            print(x,y,h)
            exit()
def bfs(start, maze, visited):
    queue = [start]
    visited[start[0]][start[1]] = True
    dist = {(start[0], start[1]): 0}
    max_dist = 0
    while queue:
        y, x = queue.pop(0)
        for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            x_, y_ = x + i, y + j
            if y_ >= 0 and y_ < h and x_ >= 0 and x_ < w and maze[y_][x_] == "." and not visited[y_][x_]:
                queue.append((y_, x_))
                visited[y_][x_] = True
                dist[y_, x_] = dist[y, x] + 1
                max_dist = max(max_dist, dist[y_, x_])
    return max_dist


h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]
max_dist = 0
for sy in range(h):
    for sx in range(w):
        if maze[sy][sx] == "." and maze[gy][gx] == ".":
            visited = [[False for _ in range(w)] for _ in range(h)]
            max_dist = max(max_dist, bfs((sy, sx), maze, visited))
print(max_dist)


### FIXED CODE ###

def bfs(start, maze, visited):
    queue = [start]
    visited[start[0]][start[1]] = True
    dist = {(start[0], start[1]): 0}
    max_dist = 0
    while queue:
        y, x = queue.pop(0)
        for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            x_, y_ = x + i, y + j
            if y_ >= 0 and y_ < h and x_ >= 0 and x_ < w and maze[y_][x_] == "." and not visited[y_][x_]:
                queue.append((y_, x_))
                visited[y_][x_] = True
                dist[y_, x_] = dist[y, x] + 1
                max_dist = max(max_dist, dist[y_, x_])
    return max_dist


h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]
max_dist = 0
for sy in range(h):
    for sx in range(w):
        if maze[sy][sx] == ".":
            visited = [[False for _ in range(w)] for _ in range(h)]
            max_dist = max(max_dist, bfs((sy, sx), maze, visited))
print(max_dist)
n=input()
print(min(abs(int(n[i:i+3])-753 for i in range(len(n)))))

### FIXED CODE ###

n=input()
print(min(abs(int(n[i:i+3])-753) for i in range(len(n))))
n = int(input())
def pos_num(l):
    l_sort = l.copy()
    l_len = len(l)
    l_sort.sort()
    if l_len == 1:
        an = 0
    else:
        #print(l_sort.index(l[0])+1)
        an = (l_sort.index(l[0]))*math.factorial(l_len-1)
    #print(an)
    return an 

    

ls = list(map(int, input().split()))
an = 0
for i in range(n-1):
    b = pos_num(ls[i:])
    an += b
    #print(an)
    
print()
ll = list(map(int, input().split()))
bn = 0
for i in range(n-1):
    b = pos_num(ll[i:])
    bn += b
    #print(bn)

print(abs(an-bn))

### FIXED CODE ###

import math
n = int(input())
def pos_num(l):
    l_sort = l.copy()
    l_len = len(l)
    l_sort.sort()
    if l_len == 1:
        an = 0
    else:
        #print(l_sort.index(l[0])+1)
        an = (l_sort.index(l[0]))*math.factorial(l_len-1)
    #print(an)
    return an 

    

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

ll = list(map(int, input().split()))
bn = 0
for i in range(n-1):
    b = pos_num(ll[i:])
    bn += b
    #print(bn)

print(abs(an-bn))