Harryxun/stf_run huggingface dataset:
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


N = int(input())
S = input()
r = []
g = []
b = []
for i in range(N):
    if S[i] == 'R':
        r.append(i+1)
    if S[i] == 'G':
        g.append(i+1)
    if S[i] == 'B':
        b.append(i+1)
print(r)
print(g)
print(b)
c = [None]*100
for i in range(100):
    c[i] = [None]*100
cnt = 0
for i in range(len(r)):
    for j in range(len(g)):
        for k in range(len(b)):
            c[i][0] = r[i]
            c[i][1] = g[j]
            c[i][2] = b[k]

            if c[i][1]-c[i][0] != c[i][2]-c[i][1]:
                #print(c[i][0], c[i][1], c[i][2], 'Yes')
                cnt += 1

print(cnt)


### FIXED CODE ###

import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


N = int(input())
S = input()
L = [None]*3
L[0] = []
L[1] = []
L[2] = []
for i in range(N):
    if S[i] == 'R':
        L[0].append(i)
    if S[i] == 'G':
        L[1].append(i)
    if S[i] == 'B':
        L[2].append(i)
cnt = 0
wa = [None]*3
for i in range(3):
    wa[i] = [0]*(N+1)
for i in range(3):
    for j in range(N):
        if S[j] == "RGB"[i]:
            wa[i][j+1] = 1
for i in range(3):
    for j in range(N):
        wa[i][j+1] = wa[i][j]+wa[i][j+1]
for x in itertools.permutations([0, 1, 2]):
    r = L[x[0]]
    g = L[x[1]]
    b = L[x[2]]
    for i in range(len(r)):
        for j in range(len(g)):
            if r[i] < g[j]:
                cnt += wa[x[2]][N]-wa[x[2]][g[j]+1]
                if len(S) > (g[j]-r[i])+g[j] and S[(g[j]-r[i])+g[j]] == "RGB"[x[2]]:
                    cnt -= 1
print(cnt)
NM = list(map(int, input().split()))
b = []
for i in range(NM[1]):
	ab = list(map(int, input().split()))
	flag = 1
	for i in range(b):
		if (b[i][1] < ab[0] and b[i][0] < ab[0] ):
			b[i][0] = ab[0]
			flag = 0
			break
		if(b[i][0] > ab[1] and b[i][1] > ab[1]):
			b[i][1] = ab[1] 
			flag = 0
			break
		if (flag):
			b.append(ab)
			flag = 1

print(len(b))

### FIXED CODE ###

N, M = map(int, input().split())
claim = []
for i in range(M):
	claim.append(list(map(int, input().split())))
claim.sort(key=lambda a:a[1])

ans = 0
inter = [-1,-1]
for land in claim:
    if inter[1] <= land[0]:
        inter = land
        ans += 1
print(ans)
S = input()
s = set(input())
print('Yes' if len(s)>1 else 'No')



### FIXED CODE ###

s = set(input())
print('Yes' if len(s)>1 else 'No')
import sys

sys.setrecursionlimit(100000)


def get_ncr():
    cache = {}

    def f(*args):
        if args in cache:
            return cache[args]
        n, r = args
        if r == 0 or n == r:
            cache[args] = 1
            return 1
        cache[args] = f(n - 1, r) + f(n - 1, r - 1)
        return cache[args]

    return f


def find_duplicated(aa):
    appeared = [-1] * (n + 1)
    for i, a in enumerate(aa):
        if appeared[a] >= 0:
            return appeared[a], i
        appeared[a] = i


n = int(input())
aa = list(map(int, input().split()))
i1, i2 = find_duplicated(aa)
pre_n = i1
mid_n = i2 - i1 + 1
post_n = n + 1 - i2 - 1
ncr = get_ncr()
div = int(1e9 + 7)

for total in range(1, n + 2):
    ans = 0
    for i in range(max(total - pre_n - post_n, 0), min(total, mid_n) + 1):
        if i == 1:
            ic = mid_n - 1
        else:
            ic = ncr(mid_n, i)
        for j in range(max(total - i - post_n, 0), min(total - i, pre_n) + 1):
            k = total - i - j
            ans = (ans + ic * ncr(pre_n, j) * ncr(post_n, k)) % div
    print(ans)


### FIXED CODE ###

def ncr(n, r):
    return fact[n] * inv_fact[r] * inv_fact[n - r] % div


def find_duplicated(aa):
    appeared = [-1] * (n + 1)
    for i, a in enumerate(aa):
        if appeared[a] >= 0:
            return appeared[a], i
        appeared[a] = i


div = int(1e9 + 7)
n = int(input())
aa = list(map(int, input().split()))

fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, n + 2):
    fact_tmp *= i
    fact_tmp %= div
    fact.append(fact_tmp)
    inv_fact.append(pow(fact_tmp, div - 2, div))

i1, i2 = find_duplicated(aa)
outside_n = n + 1 - (i2 - i1 + 1)

for part_n in range(1, n + 2):
    sub = ncr(outside_n, part_n - 1) if outside_n >= part_n - 1 else 0
    print((ncr(n + 1, part_n) - sub) % div)
x, n = map(int,input().split())
if n != 0:
  p = list(map(int,input().split()))
p_change = []
m = 0
if n == 0:
  print(x)

for i in p:
    p_change.append(abs(i-x))

if x in p:
	pass
else:
  print(x)
    
for i in range(n):
    if i != 0 and p_change.count(i) != 2:
        m = i
        break
if x-m in p_change:
    print(x+m)
else:
    print(x-m)




### FIXED CODE ###

x, n = map(int,input().split())
if n != 0:
  p = list(map(int,input().split()))
p_change = []
m = 0
if n == 0:
  print(x)
else:
    for i in p:
        p_change.append(abs(i-x))
 
    if x in p:
        for i in range(n+1):
            if i != 0 and p_change.count(i) != 2:
                m = i
                break
        if x-m in p:
            print(x+m)
        else:
            print(x-m)
    else:
        print(x)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
for i in range(1, n):
    a[i] += a[i-1]
for i in range(1, m):
    b[i] += b[i-1]
for i in range(n):
    if a[i] > k:
        break;
    while a[i]+b[m-1] > k:
        m -= 1
    c = max(c, i+m+1)
print(c)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0]
d = [0]
for i in range(n):
    c.append(a[i]+c[i])
for i in range(m):
    d.append(b[i]+d[i])
e = 0
for i in range(n+1):
    if c[i] > k:
        break;
    while c[i]+d[m] > k:
        m -= 1
    e = max(e, i+m)
print(e)
R = int.input()
print(R*2*3.14)

### FIXED CODE ###

print(int(input())*2*3.14)
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = []
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr or n in arr:
        a.append(arr)
l = [i[0] for i in a if i[1]==n]
if len(l)==0:
    print("IMPOSSIBLE")
    exit()
for i in l:
    if [1,i] in a:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

### FIXED CODE ###

n,m = map(int,input().split())
if m == 1:
    print("IMPOSSIBLE")
    exit()
a = set()
b = set()
for i in range(m):
    arr = list(map(int,input().split()))
    if 1 in arr:a.add(arr[1])
    if n in arr:b.add(arr[0])
if len(a&b)==0:print("IMPOSSIBLE")
else:print("POSSIBLE")
N, M = map( int, input().split())
A = list( map( int, input().split()))
C = [0,2,5,5,4,5,6,3,7,6]
dp = [(0,0)]*(N+1)
for a in A:
    dp[C[a]] = (1,0)
Z = sorted(list( set( C[a] for a in A)))
for i in range(2,N+1):
    for z in Z:
        if i >= z:
            if dp[i-z][0] == 1:
                dp[i] = (1, i-z)
                break
    print(dp)
s = N
ANS = [0]*10
while s != 0:
    _, b = dp[s]
    ANS[s-b] += 1
    if s == b:
        break
    s = b
ans = ""
for i in range(9,0,-1):
    if ANS[C[i]] > 0:
        if i in A:
            ans += str(i)*ANS[C[i]]
            ANS[C[i]] = 0
print( ans)

### FIXED CODE ###

N, M = map( int, input().split())
A = list( map( int, input().split()))
Needs = [0,2,5,5,4,5,6,3,7,6]
A.sort(reverse = True)
V = [0]*10
Check = []
for a in A:
    if V[Needs[a]] == 0:
        Check.append(Needs[a])
        V[Needs[a]] = a
Check.sort()
dp = [-100000]*(N+1)
dp[0] = 0

for x in Check:
    if x <= N:
        dp[x] = 1
for i in range(1,N):
    t = dp[i]
    for x in Check:
        if x + i <= N:
            if dp[x+i] < t + 1:
                dp[x+i] = t+1
ans = ""
t = N
W = [0]*10
while t > 0:
    for a in A:
        x = Needs[a]
        if t-x>=0:
            if dp[t-x]+1 == dp[t]:
                W[V[x]] += 1
                t -= x
                break
for i in range(9,0,-1):
    ans += str(i)*W[i]
print(ans)
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
l, r = map(int, input().split())
print(t[r-1] - t[l-1])

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
# coding: utf-8
def maxHeapify(A, i):
    l = A[2*(i+1)-1]
    r = A[2*(i+1)]
    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r <= H and A[r] > A[largest]:
        largest = r
    if largest != i:???# i ???????????????????????§????????´???
        A[i],A[largest] = A[largest],A[i]
        maxHeapify(A, largest) # ?????°??????????????????
        
def buildMaxHeap(A):
    for i in range(H/2,0,-1):
        maxHeapify(A,i)

H = int(raw_input())
A = map(int, raw_input().split())
buildMaxHeap(A)
print A

### FIXED CODE ###

# coding: utf-8
def maxHeapify(A, i):
    l = 2*i
    r = 2*i+1
    
    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
        
    if r <= H and A[r] > A[largest]:
        largest = r
    if largest != i:
        A[i],A[largest] = A[largest],A[i]
        maxHeapify(A, largest)
        
def buildMaxHeap(A):
    for i in range(H/2,0,-1):
        maxHeapify(A,i)

H = int(raw_input())
A = map(int, [0]+raw_input().split())
buildMaxHeap(A)
print " " + " ".join(map(str,A[1:]))
(n, m) = [int(i) for i in input().split()]
a = [[]]
b = []
for i in range(n):
    A.append([int(j) for j in input().split()]

for i in range(m):
    b.append(int(input()))

c = []
for i range(n):
    s = 0
    for j in range(m):
        m += A[i][j] * b[j]
    print(m)

### FIXED CODE ###

(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])
 
for r in range(m):
    b.append(int(input()))
 
for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)
s = input()
for i in range(len(n)):
  if 'hi' in s[i:i+2]:
    pass
  else:
    print('No')
    exit()
print('Yes')

### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict(list)
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    for i in range(0,len(s),2):
        #print(s[i:i+2])
        if s[i:i+2] == 'hi':
            pass
        else:
            print('No')
            exit()
    print('Yes')
if __name__ == '__main__':
  main()
H,W,N = [int(input()) for i in range(3)]
o = int()
a = N / o
for o in range(1,10000):
  if H < W and a <= W:
    print(o)
    break
  elif H> W and a<=H:
    print(o)
    break
    
  
  

   
    
    
    





	

  
  
  



### FIXED CODE ###

H,W,N = [int(input()) for i in range(3)]
for o in range(1,10000):
  if H <= W and N / o <= W:
    break
  elif H >= W and N / o <= H:
    break
print(o)
N,M = map(int,input().split())
check = [0]*N
ac = 0
penalty = 0
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if check[pi-1] == -1:
    continue
  if si == 'WA':
    check[pi-1] += 1
  else:
    ac += 1
    penalty += check[pi-1]
    check[pi-1] = -1
print(ac,wa)


### FIXED CODE ###

N,M = map(int,input().split())
check = [0]*N
ac = 0
penalty = 0
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if check[pi-1] == -1:
    continue
  if si == 'WA':
    check[pi-1] += 1
  else:
    ac += 1
    penalty += check[pi-1]
    check[pi-1] = -1
print(ac,penalty)
a

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    K = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    cur=7%K
    cnt=1
    for _ in range(K+1):
        if cur==0:
            print(cnt)
            return
        cur*=10
        cur+=7
        cur%=K
        cnt+=1
    print(-1)




if __name__ == "__main__":
    main()
n, m = map(int,input().split())
a = [int(input()) for i in range(m)]
b = [0] * (m+1)
b[0] = a[0] - 1
b[m] = n - a[-1] - 1
if m >= 2:
    for i in range(m-1, 0, -1):
        b[i] = a[i] - a[i-1] - 1
if 0 in b:
    print("0")  
else:         
    ans = 1
    step = [0] * (n+1)
    step[0] = 1
    step[1] = 1
    for i in range(2, n+1):
        step[i] = step[i-1] + step[i-2]
    for i in b:
        ans = ans * step[i]
    print(ans)  

### FIXED CODE ###

import sys
n, m = map(int,input().split())
a = [int(input()) for i in range(m)]
b = [0] * (m+1)
ans = 1
step = [0] * (n+1)
step[0] = 1
step[1] = 1
for i in range(2, n+1):
    step[i] = (step[i-1] + step[i-2]) % 1000000007
if m == 0:
    print(step[n])
    sys.exit()
for i in range(m-1):
    if a[i] + 1 == a[i+1]:
        print("0")
        quit()
if m > 0:
    b[0] = a[0] - 1
    b[m] = n - a[-1] - 1   
if m >= 2:
    for i in range(m-1, 0, -1):
        b[i] = a[i] - a[i-1] - 2
for i in b:
    ans = ans * step[i] % 1000000007
print(ans)
a,*b,c = intput()
print(a+str(len(b))+c)

### FIXED CODE ###

a = input()
print(a[0],len(a)-2,a[-1],sep='')
s=input()
k=int(input())
x=[]
for i in range(len(s)):
     for j in range(1,len(s)-i+1):
          x.append(s[i:i+j])
x=list(set(x))
x.sort()
print(x[k-1])

### FIXED CODE ###

s=input()
k=int(input())
x=set()
for i in range(len(s)):
     for j in range(1,min(len(s)-i+1,k+1)):
          x.add(s[i:i+j])
x=list(x)
x.sort()
print(x[k-1])
N, X = map(int, input().split())

if X < N :
    print(0)
else :
    burger = [-1] * (N + 1)
    def makeBurger(level) :
        if level == 0 :
            return '1'
        if burger[level] == -1 :
            middle = makeBurger(level - 1)
            burger[level - 1] = middle
        else :
            middle = burger[level - 1]
        return '0' + middle + '1' + middle + '0'
    ans = makeBurger(N)[:X]
    print(ans.count('1'))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

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

if X < N :
    print(0)
else :
    pat = [0] * (N + 1)  # パティ数
    ban = [0] * (N + 1)  # バンズ数
    pat[0] = 1
    for i in range(1, N + 1) :
        pat[i] = 2 * pat[i - 1] + 1
        ban[i] = 2 * ban[i - 1] + 2
    def sol(level, height) :
        if height <= 0 :
            return 0
        if level == 0 :
            return 1
        if height <= 1 :
            return 0
        if height < pat[level - 1] + ban[level - 1] :
            return sol(level - 1, height - 1)
        if height == pat[level - 1] + ban[level - 1] + 1 :
            return pat[level - 1]
        if height == pat[level - 1] + ban[level - 1] + 2 :
            return pat[level - 1] + 1
        return pat[level - 1] + 1 + sol(level - 1, height - (pat[level - 1] + ban[level - 1] + 2))

    ans = sol(N, X)
    print(ans)
N = input()
K = input()
X = input()
Y = input()

if N > K:
    res = K*X + (N-K)*Y 
else
    res = N*X

print(res)


### FIXED CODE ###

N = input()
K = input()
X = input()
Y = input()

if N > K:
    res = K*X + (N-K)*Y 
else:
    res = N*X

print(res)
n,m,k = map(int,input().split())
a = list(map(int.input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
  a[i] += a[i-1]
for  i in range(1,m):
  b[i] += b[i-1]
ans = -100
for i in range(n):
  for j in range(m):
    if(a[i]+b[j]>=k):
      break
    ans = max(ans,a[i]+b[j])
print(ans)

### FIXED CODE ###

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

a,b=[0],[0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans = 0
j = M
for i in range(N + 1): 
  if a[i]>K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)
N = int(input())
st = input().split()
A = [0 for i in range(N)]
for i in range(N):
  A[i] = int(st[i])

A.sort(reverse = True)
U = []
for i in range(N-1):
  if A[i] == A[i+1]:
    U.append(A[i])
    A[i] = -1
    A[i+1] = -1
  if len(U) >= 2:
    break
print(U[0] * U[1])


### FIXED CODE ###

N = int(input())
st = input().split()
A = [0 for i in range(N)]
for i in range(N):
  A[i] = int(st[i])

A.sort(reverse = True)
U = []
for i in range(N-1):
  if A[i] == A[i+1]:
    U.append(A[i])
    A[i] = -1
    A[i+1] = -1
  if len(U) >= 2:
    break
if len(U) >= 2:
	print(U[0] * U[1])
else:
  print(0)
a = int(input())
b = input()
c = input()
d = input()
e = int(input())
k = input()
x = e-a
if x <= k:
    print("Yay!")
else:
    print(":(")


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e - a <= k:
    print("Yay!")
else:
    print(":(")
h,w=map(int,input().split())
a,s=[],[["x"for i in range(w+2)]]
for i in range(h):
  t,tt=input(),[]
  for j in range(w):
    if t[j]=="#":a.append([i+1,j+1])
    tt.append(t[j])
  s.append(["x"]+tt+["x"])
s.append(["x"for i in range(w+2)])
f=1
while 1:
  b=[]
  for k in a:
    i,j=k[0],k[1]
    if s[i-1][j]==".":s[i-1][j]=f;b.append([i-1,j])
    if s[i+1][j]==".":s[i+1][j]=f;b.append([i+1,j])
    if s[i][j-1]==".":s[i][j-1]=f;b.append([i,j-1])
    if s[i][j+1]==".":s[i][j+1]=f;b.append([i,j+1])
  a=b.copy()
  f+=1
  if len(a)==0:break
print(f-2)

### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
d=deque()
dc=0
b=[]
for i in range(h):
  t=[]
  s=input()
  for j in range(w):
    if s[j]=="#":d.append((i,j));dc+=1;t.append(1)
    else:t.append(0)
  b.append(t)
count=0
while dc!=0:
  ld=dc
  dc=0
  for i in range(ld):
    x=d.popleft()
    if x[0]<h-1:
      if b[x[0]+1][x[1]]==0:b[x[0]+1][x[1]]=1;d.append((x[0]+1,x[1]));dc+=1
    if 0<x[0]:
      if b[x[0]-1][x[1]]==0:b[x[0]-1][x[1]]=1;d.append((x[0]-1,x[1]));dc+=1
    if x[1]<w-1:
      if b[x[0]][x[1]+1]==0:b[x[0]][x[1]+1]=1;d.append((x[0],x[1]+1));dc+=1
    if 0<x[1]:
      if b[x[0]][x[1]-1]==0:b[x[0]][x[1]-1]=1;d.append((x[0],x[1]-1));dc+=1
  count+=1
print(count-1)
A, B, C, X, Y = map(int, input().split())
 
cost = 0
 
if A + B <= 2 * C:
    cost = A * X + B * Y
elif A + B > 2 * C:
    if X > Y:
        cost = C * 2 * Y
        if 2 * C < A:
            cost += 2 * C * (X - Y)
        else:
            cost += A * (X - Y)
    elif Y >= X:
        cost = C * 2 * X
        if 2 * C < B:
            cost += 2 * C * (Y - X)
        else:
            cost += B * (Y - X)
print(cost)
A, B, C, X, Y = map(int, input().split())

cost = 0

if A + B <= 2 * C:
    cost = A * X + B * Y
elif A + B > 2 * C:
    if X > Y:
        cost = C * 2 * Y
        if 2 * C < A:
            cost += 2 * C * (X - Y)
        else:
            cost += A * (X - Y)
    elif Y >= X:
        cost = C * 2 * X
        if 2 * C < B:
            cost += 2 * C * (Y - X)
        else:
            cost += B * (Y - X)
print(cost)



### FIXED CODE ###

A, B, C, X, Y = map(int, input().split())
cost = 0
if A + B <= 2 * C:
    cost = A * X + B * Y
elif A + B > 2 * C:
    if X > Y:
        cost = C * 2 * Y
        if 2 * C < A:
            cost += 2 * C * (X - Y)
        else:
            cost += A * (X - Y)
    elif Y >= X:
        cost = C * 2 * X
        if 2 * C < B:
            cost += 2 * C * (Y - X)
        else:
            cost += B * (Y - X)
print(cost)
s  = input()
print(s // 3600, end="")
print(":", end="")
print(s // 60, end="")
print(":", end="")
print(s % 60)

### FIXED CODE ###

t=int(input())
print(f"{t//3600}:{t//60%60}:{t%60}")
import sys
for line in sys.stdin:
    xy = sorted(map(int , line.split()))
    if xy[0] == 0 and xy[1] == 0: break
    print(*xy)


### FIXED CODE ###

while True:
 x,y = map(int, input().split())
 if x==0 and y==0:
  break
 if x <= y:
  print(x,y)
 else:
  print(y,x)