Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline

n, m, q = [int(i) for i in input().strip().split()]
abcd = []
canditates = []
ans = 0


for _ in range(q):
    abcd.append([int(i) for i in input().strip().split()])


def helper(_min, _max, cur, res):
    try:
        if res == 0:
            canditates.append(list(cur))
        else:
            for i in range(_min, _max):
                cur.append(i)
                helper(i, _max, cur, res - 1)
                cur.pop()
    except BaseException:
        pass


helper(1, m + 1, [], m)

for A in canditates:
    _temp = 0
    for a, b, c, d in abcd:
        if A[b - 1] - A[a - 1] == c:
            _temp += d
    ans = max(ans, _temp)

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline

n, m, q = [int(i) for i in input().strip().split()]
abcd = []
canditates = []
ans = 0


for _ in range(q):
    abcd.append([int(i) for i in input().strip().split()])


def helper(_min, _max, cur, res):
    if res == 0:
        canditates.append(list(cur))
    else:
        for i in range(_min, _max):
            cur.append(i)
            helper(i, _max, cur, res - 1)
            cur.pop()


helper(1, m + 1, [], n)

for A in canditates:
    _temp = 0
    for a, b, c, d in abcd:
        if A[b - 1] - A[a - 1] == c:
            _temp += d

    ans = max(ans, _temp)

print(ans)
n = int(input())
s=[]
alp = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
word = []
while n > 0:
    s.append(n % 26)
    n = n // 26
for  m in s:
    if m == 0:
        word.append[z]
    else:
        word.append(alp[m-1])
word.reverse()
print("".join(word))

### FIXED CODE ###

from collections import deque
n = int(input())
st  = deque()
while n > 0:
    num = (n - 1) % 26
    n = (n - 1) // 26
    st.appendleft(chr(num + 97))
print(*st, sep = "")
j = {
    "-":-1,
    "+":1
    }
l =input().split(" ")
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)

### FIXED CODE ###

j = {
    "-":-1,
    "+":1
    }
l =input()
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
z = input()
n = int(z) +1
print(l[n])

### FIXED CODE ###

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
z = input()
n = int(z) - 1
print(l[n])
n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
print(abs(l[0]) - l[-1])

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
print(abs(int(l[0]) - int(l[-1])))
N = int(input())
s = str(N)
n = 0
for i in s:
  n += int(i)
  
if N%n==0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
N = len(S)
s1 = S[:(N-1)//2]
s2 = S[(N+3)//2-1:]

if S == S[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
  print("Yes")
else:
  print("No")
n,k=map(int,input().split())
li=list(map(int,input().split()))
kai=[0]
for i in range(1,1001):
  kai.append(kai[i-1]+i)
li.sort(reverse=True)
ans=0
for i in li[:k]:
  ans+=kai(i)/i
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
li=list(map(int,input().split()))
kai=[0]
for i in range(1,1001):
  kai.append(kai[i-1]+i)
ka=[0]+[kai[i]/i for i in range(1,len(kai))]
lis=[ka[i] for i in li]

ans=sum(lis[:k])
mx=ans
for i in range(len(li)-k):
  ans-=lis[i]
  ans+=lis[i+k]
  mx=max(ans,mx)
print(mx)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    S = list(map(int, input().split()))
    odd = {}
    even = {}
    for i in range(N):
        if i % 2 == 0:
            if S[i] not in even:
                even[S[i]] = 1
            else:
                even[S[i]] += 1
        else:
            if S[i] not in odd:
                odd[S[i]] = 1
            else:
                odd[S[i]] += 1

    n = 1000000000
    even_max1 = None
    even_max2 = None
    for ek, ev in even.items():
        if even_max1 is None:
            even_max1 = ek
        elif even_max2 is None:
            even_max2 = ek
        elif ev > even[even_max1]:
            even_max1 = ek
        elif ev > even[even_max2]:
            even_max2 = ek

    odd_max1 = None
    odd_max2 = None
    for ok, ov in odd.items():
        if odd_max1 is None:
            odd_max1 = ok
        elif odd_max2 is None:
            odd_max2 = ok
        elif ov > odd[odd_max1]:
            odd_max1 = ok
        elif ov > odd[odd_max2]:
            odd_max2 = ok

    n = min(n, N - even[even_max1] - odd[odd_max1] if even_max1 != odd_max1 else
            N - max(even[even_max1], odd[odd_max1]))
    if even_max2 is not None:
        n = min(n, N - even[even_max1] - odd[odd_max2] if even_max1 != odd_max2 else
                N - max(even[even_max1], odd[odd_max2]))
        n = min(n, N - even[even_max2] - odd[odd_max1] if even_max2 != odd_max1 else
                N - max(even[even_max2], odd[odd_max1]))
        n = min(n, N - even[even_max2] - odd[odd_max2] if even_max2 != odd_max2 else
                N - max(even[even_max2], odd[odd_max2]))

    print(n)

main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    S = list(map(int, input().split()))
    odd = {}
    even = {}
    for i in range(N):
        if i % 2 == 0:
            if S[i] not in even:
                even[S[i]] = 1
            else:
                even[S[i]] += 1
        else:
            if S[i] not in odd:
                odd[S[i]] = 1
            else:
                odd[S[i]] += 1

    n = 1000000000
    emk = None
    ev1 = None
    ev2 = 0
    for ek, ev in even.items():
        if emk is None:
            emk = ek
            ev1 = ev
        elif ev > ev1:
            emk = ek
            ev2 = ev1
            ev1 = ev
        elif ev > ev2:
            ev2 = ev

    omk = None
    ov1 = None
    ov2 = 0
    for ok, ov in odd.items():
        if omk is None:
            omk = ok
            ov1 = ov
        elif ov > ov1:
            omk = ok
            ov2 = ov1
            ov1 = ov
        elif ov > ov2:
            ov2 = ov

    if emk != omk:
        n = min(n, N - ev1 - ov1)
    else:
        n = min(n, N - ev1 - ov2, N - ev2 - ov1)

    print(n)

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

A=N[0]
B=N[1]
C=N[2]

Answerlist= [0 for i in range(3)]
Answerlist[0]=abs(A-B)
Answerlist[1]=abs(B-C)
Answerlist[2]=abs(C-A)

print(max(Answerlist))

### FIXED CODE ###

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

A=N[0]
B=N[1]
C=N[2]

Answerlist= [0 for i in range(3)]
Answerlist[0]=abs(A-B)
Answerlist[1]=abs(B-C)
Answerlist[2]=abs(C-A)

print(max(Answerlist))
import numpy as np

n = int(input())

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

y = np.zeros((n, 1), dtype=np.int)

for i, wa in enumerate(a):
    y[i][0] = wa
exit()
A = np.zeros((n, n), dtype=np.int)

exit()



### FIXED CODE ###

import numpy as np
import sys

n = int(input())

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

a_sum = sum(a)
# x[i]はi番目のダムに溜まった水の半分
x = []

x_0 = int(a_sum/2)

for i in range(int((n-1)/2)):
    x_0 -= a[2*i+1]

x.append(x_0)
x_tmp = x_0

for i in range(n-1):
    x_tmp = a[i] - x_tmp
    x.append(x_tmp)

for wa in x:
    print(wa*2, end=' ')
s=[reversed(list(input())) for i in range(3)]
flag=True
next=0
ans=0
ans_s=["a","b","c"]
while(flag):
  if len(s[next]) >0:
    tmp=s[next].pop()
    next=ans_s.index(tmp)
  else:
    ans=next
    flag=False
print(ans_s[ans])

### FIXED CODE ###

s=[list(input()) for i in range(3)]
for i in range(3):
  s[i]=list(reversed(s[i]))
flag=True
next=0
ans=0
mem_s=["a","b","c"]
ans_s=["A","B","C"]
while(flag):
  if len(s[next]) >0:
    tmp=s[next].pop()
    next=mem_s.index(tmp)
  else:
    ans=next
    flag=False
print(ans_s[ans])
s = input()
a = int(s[0])
b = int(s[2])

print(a*b, 2*(a+b))


### FIXED CODE ###

a,b = map(int, input().split())
print(a*b, 2*(a+b))
# https://atcoder.jp/contests/abc145/tasks/abc145_d

X, Y = map(int, input().split())

if (2*Y- X) % 3 or (2*X- Y) % 3:
    print(0)
    exit()

x = (2*Y - X) // 3
y = (2*X - Y) // 3

n = x + y
r = x


mod = 10**9 + 7
f = 1
for i in range(1, n + 1):
    f = f*i % mod
fac = f
f = pow(f, mod-2, mod)
facinv = [f]
for i in range(n, 0, -1):
    f = f*i % mod
    facinv.append(f)

print(fac * facinv[r] * facinv[n - r] % mod)

### FIXED CODE ###

# https://atcoder.jp/contests/abc145/tasks/abc145_d


class Combination:                                      # 計算量は O(n_max + log(mod))
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):                     # 階乗(= n_max !)の逆元を生成
            f = f * i % mod                             # 動的計画法による階乗の高速計算
            fac.append(f)                               # fac は階乗のリスト
        f = pow(f, mod-2, mod)                          # 階乗から階乗の逆元を計算。フェルマーの小定理より、　a^-1 = a^(p-2) (mod p) if p = prime number and p and a are coprime
                                                        # python の pow 関数は自動的に mod の下での高速累乗を行ってくれる
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):                   # 上記の階乗の逆元から階乗の逆元のリストを生成（＝ facinv ）
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

X, Y = map(int, input().split())

if (2*Y- X) % 3 or (2*X- Y) % 3:
    print(0)
    exit()

x = (2*Y - X) // 3
y = (2*X - Y) // 3

n = x + y
r = x


mod = 10**9 + 7
f = 1
for i in range(1, n + 1):
    f = f*i % mod
fac = f
f = pow(f, mod-2, mod)
facinv = [f]
for i in range(n, 0, -1):
    f = f*i % mod
    facinv.append(f)
facinv.append(1)

comb = Combination(n)
print(comb.C(n,r))
n = int(input())
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

N = input()
if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
	print('Yes')
else:
	print('No')
cnt = int(input())
li = list(map(int,input().split()))
re_li = li[::-1]
print(' '.join(map(int,re_li)


### FIXED CODE ###

cnt = int(input())
li = list(map(int,input().split()))
re_li = li[::-1]
print(' '.join(map(str,re_li)))
import math

def main():
  r = int(input())
  print('{:.16}'.format(2*r*math.pi)

if __name__ == '__main__':
  main()

### FIXED CODE ###

import math

def main():
  r = int(input())
  print('{:.20}'.format(2*r*math.pi))

if __name__ == '__main__':
  main()
def minimum(a):
    b=a.copy()
    if len(b)==1:
        return b[0]
    else:
        c=b.pop(-1)
        return min(c,minimum(b))

def maximum(a):
    b=a.copy()
    if len(b)==1:
        return b[0]
    else:
        c=b.pop(-1)
        return max(c,maximum(b))

def sum(a):
    b=a.copy()
    if len(b)==1:
        return b[0]
    else:
        c=b.pop(-1)
        return c+sum(b)




n=int(input())
a=[int(i) for i in input().split(" ")]

print("{0} {1} {2}".format(minimum(a),maximum(a),sum(a)))

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split(" ")]

print("{0} {1} {2}".format(min(a),max(a),sum(a)))
n,m=map(int,input().split())
print("Yes" if n==m: else: "No")

### FIXED CODE ###

n,m=map(int,input().split())
if n==m:
  print("Yes")
else:
  print("No")
import copy
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = True
if n % 2 == 1:
    if a[0] != 0:
        print(0)
    else:
        ans = [i for i in range(2, n, 2) for j in range(2)]
        ans.insert(0, 0)
        if ans != a:
            print(0)
            flag = False
    if flag:
        print((2**((n - 1) // 2)) % (1e9 + 7))

else:
    ans = [i for i in range(1, n, 2) for j in range(2)]
    if ans != a:
        print(0)
        flag = False
    if flag:
        print((2**(n // 2)) % (1e9 + 7))


### FIXED CODE ###

print(eval(input()))
def gcd(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            return gcd(a-b,b)
        else:
            return gcd(a,b-a)

def lcm(a,b):
   return int(a*b/gcd(a,b)) 
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))

### FIXED CODE ###

def gcd(a,b):
    if a==0 or b==0:
        return max([a,b])
    else:
        if a>=b:
            n=int(a/b)
            return gcd(a-n*b,b)
        else:
            n=int(b/a)
            return gcd(a,b-n*a)

def lcm(a,b):
   return int(a*b/gcd(a,b)) 
a=input().split(" ")
print(lcm(int(a[0]),int(a[1])))
n, k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
import time

if n >= k:
    ans = -float('inf')
    for i in range(n):
        now = i
        score = []
        for j in range(k):
            now = p[now] - 1
            if j == 0:
                score.append(c[now])
            else:
                score.append(score[j-1] + c[now])
        ans = max(max(score), ans)
else:
	time.sleep(10)

### FIXED CODE ###

s = input()


if 'RRR' in s:
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)
import itertools

def q49(n, k, h):
    h.sort()
    a = [h[i+k-1]-h[i] for i in range(n-k-1)]
    return min(a)
            
N, K = [int(i) for i in input().split()]
h = []
for _ in range(N):
    h.append(int(input()))
print(q49(N, K, h))

### FIXED CODE ###

import itertools

def q49(n, k, h):
    h.sort()
    a = [h[i+k-1]-h[i] for i in range(n-k+1)]
    return min(a)
            
N, K = [int(i) for i in input().split()]
h = []
for _ in range(N):
    h.append(int(input()))
print(q49(N, K, h))
import sys
n, k = map(int, sys.stdin.buffer.read().split())
rem = n % k
print(min(rem, k - rem)

### FIXED CODE ###

import sys
n, k = map(int, sys.stdin.buffer.read().split())
rem = n % k
print(min(rem, k - rem))
import numpy as np

N, X, Y = map(int, input().split())
X -= 1
Y -= 1

ans = [0] * (N-1)

c = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        d1 = abs(j - i)
        d2 = abs(X - i) + 1 + abs(j - Y)
        d3 = abs(Y - i) + 1 + abs(j - X)
        ans[min(d1, d2, d3) - 1] += 1

[print(ans[i]) for i in range(N - 1)]


### FIXED CODE ###

import numpy as np

N, X, Y = map(int, input().split())
X -= 1
Y -= 1

ans = [0] * (N-1)

for i in range(N - 1):
    for j in range(i + 1, N):
        d1 = abs(j - i)
        d2 = abs(X - i) + 1 + abs(j - Y)
        ans[min(d1, d2) - 1] += 1

[print(ans[i]) for i in range(N - 1)]
mod = 10**9+7

def stairs(n):
    if n ==0:
        return 1
    if n ==1:
        return 1
    else:
        return stairs(n-1)+stairs(n-2)
def main():
    n,m=map(int,input().split(' '))
    a = [-1]
    a_dis=[]
    ans = 1
    for i in range(m):
        a.append(int(input()))
    for i in range(m):
        a_dis.append(a[i+1]-a[i]-2)
    a_dis.append(n-a[-1]-1)
    for i in a_dis:
        if i <0:
            ans = 0
            break
        tmp = stairs(i)%mod
        ans *=tmp
        ans %= mod
        tmp = 0
    print(ans)

main()

### FIXED CODE ###

import sys
mod = 10**9+7
def main():
    n,m=map(int,input().split(' '))
    if m > 0:
        aaa = set(map(int,sys.stdin))
    else:
        aaa = set()

    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in aaa else 0
    for i in range(2,n+1):
        if i in aaa:
            continue
        dp[i] = dp[i-1]+dp[i-2]

    print(dp[n]%mod)

main()
ddd = [input() for i in range(2)]
eee = ddd[0].split()
fff = ddd[1].split()
longest_distance = 0

for i in range(len(fff - 1)):
    distance = fff[i+1] - fff[i]
    if longest_distance < distance:
        longest_distance = distance

shortest_road = eee[0] - longest_distance

print(shortest_road)


### FIXED CODE ###

ddd = [input() for i in range(2)]
eee = ddd[0].split()
fff = ddd[1].split()
longest_distance = int(eee[0]) + int(fff[0]) - int(fff[-1])
for i in range(len(fff) - 1):
    distance = int(fff[i+1]) - int(fff[i])
    if longest_distance < distance:
        longest_distance = distance
shortest_road = int(eee[0]) - longest_distance
print(shortest_road)
x,n = map(int, input().split())
l = map(lambda t : int(t)-x, input().split())
p = [0]
p.extend( sorted(map(abs,l)))
for i in range(n//2+1):
  if not ( p[2*i+1] == i ):
    if i in l:
      print(x-i)
    else:
      print(x+i)
    break

### FIXED CODE ###

x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:abs(y-x)))
from fractions import gcd

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

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

lcm_a = 1

for i in range(N):
    lcm_a = lcm(lcm_a,A[i])

B = np.array([])
for i in range(N):
    B = np.append(B,lcm_a//A[i])

mod = int(1e9+7)
print(int((np.sum(B)%mod)))

from fractions import gcd

### FIXED CODE ###

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

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

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

lcm_a = 1

for i in range(N):
    lcm_a = lcm(lcm_a,A[i])

ans = 0
for i in range(N):
    ans += lcm_a//A[i]

mod = int(1e9+7)

print(ans%mod)
N = int(input())
nums = [int(x) for x in input().split()]
cnt = 0
loop = True
while Loop:
  if not all([n%2 is 0 for n in nums]):
    loop = Flase 
    break
  for i, n in enumerate(nums):
    nums[1] = n//2
  cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
nums = [int(x) for x in input().split()]
cnt = 0
loop = True
while loop:
  if not all([n % 2 is 0 for n in nums]):
    loop = False 
    break
    
  for i, n in enumerate(nums):
    nums[i] = n//2
  cnt += 1
print(cnt)
a = int(input())
c = b.split('')
a = c[-1]
if (a ==2 || a== 4 || a==5 || a== 7 || a== 9){
	print("hon")
}else if(a == 0 || a== 1 || a==6 || a == 8){
	print("pon")
}else {
  print("bon")
}

### FIXED CODE ###

b = int(input())
a = b % 10
if a ==2 or a== 4 or a==5 or a== 7 or a== 9:
	print("hon")
elif a == 0 or a== 1 or a==6 or a == 8:
	print("pon")
else:
  print("bon")
if ("hi" in str(S)):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import re
index = re.fullmatch(r'(hi)+', input())
if index:
    print("Yes")
else:
    print("No")
import math
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//math.gcd(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)


### FIXED CODE ###

import math
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)
n = input()
A = ''.join(raw_input() for i in xrange(n))

if n > 5:
    exit(1)

ALL = "#"*(n*n)

memo = {}
def dfs(state):
    if state in memo:
        return memo[state]
    if state == ALL:
        return 0
    s = list(state)
    memo[state] = res = 10**9
    for i in xrange(n):
        C = [state[i*n+k] for k in xrange(n)]
        for j in xrange(n):
            n_state = s[:]
            for k in xrange(n):
                n_state[k*n+j] = C[k]
            res = min(res, dfs(''.join(n_state))+1)
    memo[state] = res
    return res
ans = dfs(A)
if ans == 10**9:
    print -1
else:
    print ans


### FIXED CODE ###

n = input()
A = [raw_input() for i in xrange(n)]

R = [sum(e[j] == '#' for j in xrange(n)) for e in A]
C = [sum(A[j][i] == '#' for j in xrange(n)) for i in xrange(n)]

c_need = sum(e < n for e in C)

INF = 10**9+7
ans = INF
for i in xrange(n):
    if R[i] == C[i] == 0:
        continue
    if C[i] == 0:
        ans = min(ans, n-R[i] + c_need + 1)
    else:
        ans = min(ans, n-R[i] + c_need)
print -1 if ans == INF else ans
import math
n, W = map(int, input().strip().split())
values = []
weights = []
total = 10
for _ in range(n):
    w, v = map(int, input().strip().split())
    weights.append(w)
    values.append(v)
    total += v
dp = [[math.inf]*total for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
for i in range(1,n+1):
    for v in range(1,total):
        if v < values[i-1]:
            dp[i][v] = dp[i-1][v]
        else:
            dp[i][v] = min(dp[i-1][v],dp[i-1][v-values[i-1]]+weights[i-1]) 
res = 0
for i in range(total):
    if dp[n][i] <= W:
        res = i
print(res)

### FIXED CODE ###

INF = 1000000000000
n, W = map(int, input().split())
values = []
weights = []
total = 10
for _ in range(n):
    w, v = map(int, input().split())
    weights.append(w)
    values.append(v)
    total += v
dp = [[INF for j in range(total)] for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
for i in range(1,n+1):
    for v in range(1,total):
        if v < values[i-1]:
            dp[i][v] = dp[i-1][v]
        else:
            dp[i][v] = min(dp[i-1][v],dp[i-1][v-values[i-1]]+weights[i-1]) 
res = 0
for i in range(total):
    if dp[n][i] <= W:
        res = i
print(res)
x = int(input())
n = [i**5 for i in range(63)]

a = 0
b = 0
res = False
i = 0
while not res:
    sign = 1 - 2*(n[i] < x)
    for j in range(i+1):
        if (n[i] - n[j] * sign) == x:
            print(i,j*sign)
            res = True
    i += 1

### FIXED CODE ###

x = int(input())
n = [i**5 for i in range(119+1)]

a = 0
b = 0
res = False
i = 0
while not res:
    sign = 1 - 2*(n[i] < x)
    for j in range(i+1):
        if (n[i] - n[j] * sign) == x:
            print(i,j*sign)
            res = True
    i += 1
while 1:
 H, W = map(int,raw_input().split())
 if H + W == 0:
???break
 for h in range(H):
  if h % 2 == 0:
   if W % 2 == 0:
    print ('#.'*(W//2))
   else:
    print ('#.'*(W//2)+'#')
  else:
   if W % 2 == 0:
    print ('.#'*(W//2))
   else:
    print ('.#'*(W//2)+'.')
 print ''

### FIXED CODE ###

while 1:
 H, W = map(int,raw_input().split())
 if H + W == 0:break
 for h in range(H):
  if h % 2 == 0:
   if W % 2 == 0:
    print ('#.'*(W//2))
   else:
    print ('#.'*(W//2)+'#')
  else:
   if W % 2 == 0:
    print ('.#'*(W//2))
   else:
    print ('.#'*(W//2)+'.')
 print ''