Harryxun/stf_run huggingface dataset:
def dfs(v):
    visited[v] = 1
    for i in AB[v]:
        if visited[i]:
            continue
        dfs(i)

def main():
    N, M = map(int, input().split())
    AB = [[] for _ in range(N)]

    for _ in range(M):
        a,b = map(lambda x: int(x)-1, input().split())
        AB[a].append(b)
        AB[b].append(a)

    visited = [0]*N
    cnt = 0
    for i in range(N):
        if visited[i]:
            continue
        dfs(i)
        cnt += 1
    print(cnt-1)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque

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

AB = [[] for _ in range(N)]

for _ in range(M):
    a,b = map(lambda x: int(x)-1, input().split())
    AB[a].append(b)
    AB[b].append(a)

visited = [0] * N
ans = []
for i in range(N):
    if visited[i]:
        continue
    group = [i]
    d = deque(AB[i])
    while d:
        s = d.popleft()
        if visited[s]:
            continue
        visited[s] = 1
        group.append(s)
        for k in AB[s]:
            d.append(k)
    ans.append(len(group))

print(len(ans)-1)
s = input()
n = len(s)
sum = [0] * (n + 1)
sum[0] = (s[0] == 'B')
for i in range(1 , n):
	sum[i] = sum[i-1] + (s[i] == 'B')
ans = 0
for i in range(n, -1 ,-1):
	print(i)
	if s[i] == 'W':
		ans += sum[i]
print(ans)
	

### FIXED CODE ###

s = input()
n = len(s)
sum = [0] * (n + 1)
sum[0] = (s[0] == 'B')
for i in range(1 , n):
	sum[i] = sum[i-1] + (s[i] == 'B')
ans = 0
for i in range(n - 1, -1 ,-1):
	if s[i] == 'W':
		ans += sum[i]
print(ans)
import math
Alp = [chr(ord('a') + i) for i in range(26)]
N = int(input())
k = math.ceil(math.log((25*N/26)+1,26))
n = N-(26*(26**(k-1)-1)/25)
for i in range(k):
  if i<k-1:
    kre = int(n//(26**(k-1-i)))
    print(Alp[kre], end='')
    n -= (26**(k-1-i))*kre
  else:
    print(Alp[int(n-1)])

### FIXED CODE ###

import math
Alp = [chr(ord('a') + i) for i in range(26)]
N = int(input())
k = int(math.ceil(math.log((25*N/26)+1,26)))
n = int(N-(26*(26**(k-1)-1)/25))
for i in range(k):
  if i<k-1:
    if n%(26**(k-1-i))!=0:
      kre = int(n//(26**(k-1-i)))
    else:
      kre = int(n/(26**(k-1-i))-1)
    print(Alp[kre], end='')
    n -= int((26**(k-1-i))*kre)
  else:
    print(Alp[n-1], end='')
import collections
import heapq

x, y, z, k = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    ls[i].sort(reverse=True)
q = [(-sum([ls[i][0] for i in range(3)]), 0, 0, 0)]
res = []
used = collections.defaultdict(lambda: False)
while len(res) < k:
    s, i, j, l = heapq.heappop(q)
    res.append(-s)
    index_list = [
        (i + 1, j, l),
        (i, j + 1, l),
        (i, j, l + 1),
    ]
    for i, (indices, limit) in enumerate(zip(index_list, [x, y, z])):
        if indices[i] < limit and not used[indices]:
            ss = sum([ls[j][l] for j, l in zip(range(3), indices)])
            heapq.heappush(q, (-ss, *indices))
            used[indices] = True
print(*res, sep='\n')

### FIXED CODE ###

import heapq


def select(ls0, ls1, k):
    ls = []
    for a in ls0:
        for b in ls1:
            heapq.heappush(ls, -(a + b))
    return [-heapq.heappop(ls) for _ in range(min(k, len(ls0) * len(ls1)))]


x, y, z, k = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    ls[i].sort(reverse=True)
ps = select(ls[0], ls[1], k)
res = select(ps, ls[2], k)
print(*res, sep='\n')
def fizzbuzz(i):
    if i % 15 == 0:
        return 'FizzBuzz'
    elif i % 5 == 0:
        return 'Buzz'
    elif i % 3 == 0:
        return 'Fizz'
    else:
        return str(i)

import sys
f = sys.stdin

while True:
    m, n = map(int, f.readline().split())
    if m == n == 0:
        break
    member = list(range(1, m + 1))
    s = [f.readline().strip() for _ in range(n)]
    offset = 0
    for i in range(n):
        if s[i] != fizzbuzz(i + 1):
            pos = (i - offset) % m
            member.remove(member[pos])
            offset = i - pos
            if len(member) == 1:
                break
        
    print(*member)

### FIXED CODE ###

def fizzbuzz(i):
    if i % 15 == 0:
        return 'FizzBuzz'
    elif i % 5 == 0:
        return 'Buzz'
    elif i % 3 == 0:
        return 'Fizz'
    else:
        return str(i)

import sys
f = sys.stdin


while True:
    m, n = map(int, f.readline().split())
    if m == n == 0:
        break
    member = list(range(1, m + 1))
    s = [f.readline().strip() for _ in range(n)]

    pos = 0
    for i in range(n):
        if s[i] != fizzbuzz(i + 1):
            del member[pos]
            m = len(member)
            if m == 1:
                break
        else:
            pos += 1
        pos %= m
        
    print(*member)
N=int(input())
A=list(map(int,input().split()))
B=A.copy()
B.sort()
A_max=B[N-1]+N
sum_A=[0]*N
for i in range(A_max+1):
  for num in range(N):
    sum_A[i]+=abs(A[num]-i)
sum_A.sort()
print(sum_A[0])
    
  
  




### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i]-(i+1))
B.sort()
if N%2==0:
  a=N/2
  b=int((B[int(a)]+B[int(a-1)])/2)
else:
  a=(N+1)/2
  b=B[int(a-1)]
for i in range(N):
  B[i]=abs(B[i]-b)
print(sum(B))
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
count=0
for i in range(len(s)):
    if s[i]==t[i]:
        count+=1
        continue
    elif s[i]<t[i]:
        print('Yes')
        count=0
        break
    else:
        print('No')
        count=0
        break
if count!=0 and len(s)<len(t):
    print('Yes')
elif count!=0 and len(s)>=len(t):
    print('No')


### FIXED CODE ###

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)

for i in range(min(len(s),len(t))):
    if s[i]==t[i]:
        count=1
        continue
    elif s[i]<t[i]:
        count=2
        break
    else:
        count=0
        break
if count==1:
    if len(s)<len(t):
        print('Yes')
    else:
        print('No')
elif count==2:
    print('Yes')
else:
    print('No')
import math

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

if M == 0:
    a = [-1 , N+1]
else :
    a = [-1] * (M+2)

    for i in range(1,M+1) :
        a[i] = int(input())

flag = True # 可能かどうか
for i in range(0,M+1) :
    if a[i] + 1 == a[i+1] :
        flag = False
        break

fib = [1] * N # フィボナッチ数列
for i in range(2,N) :
    fib[i] = fib[i-1] + fib[i-2]

if flag :
    a[M+1] = N + 1

    ans = 1

    for i in range(M+1) :
        length = a[i+1] - a[i] - 2 # 上がる長さ
        ans *= fib[length]

    print(ans % 1000000007)
else :
    print(0)

### FIXED CODE ###

import math

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

if M == 0:
    a = [-1 , N+1]
else :
    a = [-1] * (M+2)

    for i in range(1,M+1) :
        a[i] = int(input())


flag = True # 可能かどうか
for i in range(0,M+1) :
    if a[i] + 1 == a[i+1] :
        flag = False
        break

fib = [1] * (N+1) # フィボナッチ数列
for i in range(2,N+1) :
    fib[i] = fib[i-1] + fib[i-2]

if flag :
    a[M+1] = N + 1

    ans = 1

    for i in range(M+1) :
        length = a[i+1] - a[i] - 2 # 上がる長さ
        ans *= fib[length]

    print(ans % 1000000007)
else :
    print(0)
n = int(input())
s = map(int,input().split())
ans = 1

if 0 in s:
    print(0)
else:    
    for i in range(n):
        ans *= s[i]
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)

### FIXED CODE ###

n = int(input())
s = list(map(int,input().split()))
ans = 1

if 0 in s:
    print(0)
else:    
    for i in range(n):
        ans *= s[i]
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)
import sys

sys.setrecursionlimit(2000000)

def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()
S=one_str()

bit_count = S.count("1")

bit_count

#bit数
calc_dict = {i:-1 for i in range(22)}

def mods(N, m, count):
    temp = N%m
    if temp==0:
        return count+1
    
    if calc_dict[temp]==-1:
        calc_dict[temp] = bin(temp).count("1")

    return mods(temp, calc_dict[temp], count+1)

bit_count = S.count("1")
for i in range(len(S)):
    if S[i]=="0":

        bit_count+=1
        num = int(S,2) + 2**(N-i-1)
        print(mods(num, bit_count, 0))
        bit_count-=1
    else:

        bit_count-=1
        num = int(S,2) - 2**(N-i-1)
        print(mods(num, bit_count, 0))
        bit_count+=1

### FIXED CODE ###

def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()
S=one_str()

bit_count = S.count("1")
S_num = int(S,2)
S_min = S_num % (bit_count-1) if bit_count-1!=0 else 0
S_plu = S_num % (bit_count+1)




# calc_dict = {i:-1 for i in range(10000)}
# res_dict =  {i:-1 for i in range(10**4)}

# for i in range(1, 10000):
#     if calc_dict[i]==-1:
#         calc_dict[i] = bin(i).count("1")

#     res_dict[i] = i%calc_dict[i]+1

def mods(temp, count):
    count+=1
    if temp!=0:

#         if temp in res_dict:
#             return count+res_dict[temp]
        
#         if temp not in calc_dict:
#             calc_dict[temp]= bin(temp).count("1") 
        count = mods(temp%bin(temp).count("1") , count)

    return count

for i in range(N):
    if S[i]=="0":
        part = pow(2, (N-i-1), bit_count+1)
        num = (S_plu + part ) % (bit_count+1)
        print(mods(num, 0))
    else:
        if S_num == 2**(N-i-1):
            print(0)
            continue
        part = pow(2, (N-i-1), bit_count-1)
        num = (S_min - part)%(bit_count-1)
        print(mods(num, 0))
w, h, x, y = list(map(int, input().split()))
area_ans = w * h / 2
cog_x = w/2 
cog_y = h/2
if cog_x == x and cog_y == y: 
    cog_ans = 1
    print(str(area_ans) +" "+ str(cog_ans))
elif:
    cog_ans = 0
    print(str(area_ans) +" "+ str(cog_ans))

### FIXED CODE ###

w, h, x, y = list(map(int, input().split()))
area_ans = w * h / 2
cog_x = w/2 
cog_y = h/2
if cog_x == x and cog_y == y: 
    cog_ans = 1
    print(str(area_ans) +" "+ str(cog_ans))
else:
    cog_ans = 0
    print(str(area_ans) +" "+ str(cog_ans))
s = input()
t = input()
n = len(s)
if s = t[:n-1]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
t = input()
n = len(s)
if s == t[:n]:
  print("Yes")
else:
  print("No")
n,x,t=map(int,input().split())
s=ceil(n//x)
print(s*t)

### FIXED CODE ###

import math
n,x,t=map(int,input().split())
s=math.ceil(n/x)
print(s*t)
"""import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
"""
import numpy as np

def main():
    S = input()
    Q = int(input())
    #qi = [[0 for j in range(3)] for i in range(Q)]
    qi = np.zeros((Q, 3))
    for i in range(Q):
        n = input()
        if n != 1:
            qi[i]= n.split()
        else:
            qi[i][0] = 1

    for i in range(Q):

        if qi[i][0] == "1":
            S = S[::-1]
        elif qi[i][0] == "2":
            if qi[i][1] == "1":
                S = str(qi[i][2]) + S
            elif qi[i][1] == "2":
                S = S + str(qi[i][2]) 
    print(S)

if __name__ == "__main__":
	main()

### FIXED CODE ###

from collections import deque

def main():
    S = deque(input())
    
    Q = int(input())
    count = 1

    for i in range(Q):
        n = input()
        if n == "1":
            #qi[i][0] = 1
            count += 1
        else:
            q= list(n.split())
            if (count % 2 == 1 and q[1] == "1") or(count % 2 == 0 and q[1] == "2"):
                S.appendleft(q[2])
            else:
                S.append(q[2]) 

    if count % 2 == 0:
        S.reverse()
    print(''.join(S))

if __name__ == "__main__":
    main()
T=[map(int,input().split())]
T.sort()
print(T[0]+T[1])


### FIXED CODE ###

T=list(map(int,input().split()))
T.sort()
print(T[0]+T[1])
num = input().split(' ')
a = num[0]
b = num[1]
if (a*b)%2 == 0:
  print('Even')
else:
  print('Odd')

### FIXED CODE ###

num = input().split(' ')
a = int(num[0])
b = int(num[1])
if (a*b)%2 == 0:
  print('Even')
else:
  print('Odd')
n=input().split(" ")
a= int(n[0])
b= int(n[1])
print(a*b a*a+b*b)


### FIXED CODE ###

a,b = map(int, input().split())
print(a*b, 2*(a+b))
import math
n=int(input())
 
for i in range (1,n+1):
  ans=0
  for x in range(1,int(i*1/3)):
   for y in range(1,int(i*1/3)):
    for z in range(1,int(i*1/3)):
     if x+y+z==math.sqrt(i+x*y+x*z+y*z):
       ans+=1
       if x==y and y==z:
        break
  print(ans) 

### FIXED CODE ###

l,r,k=map(int,input().split())
ans=0
for i in range(l,r+1):
 if i%k==0:
  ans+=1
 else:
  pass
print(ans)
import sys
n = int(input())
sys.setrecursionlimit(n)
graph = [[] for _ in range(n)]
edge = []
for i in range(n-1):
    a, b = map(lambda x:int(x)-1, input().split())
    edge.append({a,b})
    graph[a].append(b)
    graph[b].append(a)
k = max(len(i) for i in graph)

ans = [0]*(n-1)
def DFS(cur, pre=-1, p_color=-1):
    color = 1
    for i in graph[cur]:
        if i==pre:
            continue
        if color==p_color:
            color += 1
        ans[edge.index({cur, i})] = color
        DFS(i, cur, color)
        color += 1
DFS(0)
print(k)
[print(i) for i in ans]

### FIXED CODE ###

import sys
n = int(input())
sys.setrecursionlimit(2*n)
graph = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(lambda x:int(x)-1, input().split())
    graph[a].append((b, i))
    graph[b].append((a, i))

def DFS(node, p_node=-1, p_color=-1):
    color = 1
    for c_node, edge in graph[node]:
        if c_node==p_node:
            continue
        if color==p_color:
            color += 1
        ans[edge] = color
        DFS(c_node, node, color)
        color += 1
ans = [0]*(n-1)
DFS(0)
k = max(len(i) for i in graph)
print(k)
[print(i) for i in ans]
print(''.swapcase(1200))

### FIXED CODE ###

s = input()
print(s.swapcase())
def is_prime(x, i):
  if i*i > x:
    return True
  elif x % i == 0:
    return False
  else:
    is_prime(x, i+1)
  
def gen_prime(x):
  if is_prime(x, 2):
    return x
  else:
    gen_prime(x+1)
    
if __name__ == "__main__":
  import sys
  sys.setrecursionlimit(10240)
  x = int(input())
  print(gen_prime(x))


### FIXED CODE ###

def is_prime(x, i):
  if i*i > x:
    return True
  elif x % i == 0:
    return False
  else:
    return is_prime(x, i+1)
  
def gen_prime(x):
  if is_prime(x, 2):
    return x
  else:
    return gen_prime(x+1)
    
if __name__ == "__main__":
  import sys
  sys.setrecursionlimit(10240)
  x = int(input())
  print(gen_prime(x))
a = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in alphabet:
    print(i + " : " + a.lower().count() )

### FIXED CODE ###

import sys

a = sys.stdin.read()
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in alphabet:
    print(i + " : " + str(a.lower().count(i)) )
K = int(input())
S = input()
sentence = list(S)

for i in range(K):
  print(sentence[i], end="")

sentencelong = len(sentence)

if K < sentencelong:
  print("...")

### FIXED CODE ###

K=int(input())
S=input()

if len(S) > K:
  S = S[:K] + "..."
  
print(S)
L=[]
L2=[]
for i in range(5):
    I=int(input())
    L.append(I)
    L2.append(I%10)

result=0
for i in L:
    result+=i
    if result%10==0:
        continue
    for j in range(10):
        result+=1
        if result%10==0:
            break

if min(L2)==0:
    for t in sorted(L2):
        if t==0:
            pass
        else:
            mn=t
            break
else:
    mn=min(L2)

print(result-(10-mn))


### FIXED CODE ###

L=[]
L2=[]
for i in range(5):
    I=int(input())
    L.append(I)
    L2.append(I%10)

result=0
for i in L:
    result+=i
    if result%10==0:
        continue
    for j in range(10):
        result+=1
        if result%10==0:
            break

if max(L2)==0:
    print(sum(L))
else:
    if min(L2)==0:
        for t in sorted(L2):
            if t==0:
                pass
            else:
                mn=t
                break
    else:
        mn=min(L2)

    print(result-(10-mn))
n=int(input)
s=input()
d=list(s)
cnt=0
for i in range(n-1):
  if s[i] != s[i+1]:
    cnt+=1
print(cnt+1)




### FIXED CODE ###

n=int(input())
s=input()
d=list(s)
cnt=0
for i in range(n-1):
  if s[i] != s[i+1]:
    cnt+=1
print(1+cnt)
import math
import sys
readline = sys.stdin.readline


def main():
    x = int(readline().rstrip())
    ans = x // 100
    sur = x - ans * 100
    print(1 if sur / ans <= 5 else 0)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import sys
readline = sys.stdin.readline


def main():
    x = int(readline().rstrip())
    ans = x // 100
    if ans == 0:
        print(0)
        return

    sur = x - ans * 100
    print(1 if sur / ans <= 5 else 0)


if __name__ == '__main__':
    main()
n = int(input())
l = [int(input()) for i in range(n)]
print("Yes" if sum(l) - max(l) > max(l) else "No")

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
print("Yes" if sum(l) - max(l) > max(l) else "No")
n,m = map(int,input().split())

if n = m:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

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

if n == m:
  print("Yes")
else:
  print("No")
def solve( lst_a, lst_b,n):
    if n.count("-")>=2:
        return "No"
    else:
        N,NN=n.split("-")
        if lst_a == len(N) and lst_b == len(NN):
            answer = "Yes"
        else:
            answer = "No"
    return answer
def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    n = int(line1)
    lst_a = []
    lst_b = []
    for i in range(n):
        line = sys.stdin.readline()
        [str_a, str_b] = line.rstrip().split(' ')
        lst_a.append(int(str_a))
        lst_b.append(int(str_b))
    return (n, lst_a, lst_b)

def main():
    n, lst_a, lst_b = readQuestion()
    answer = solve(n, lst_a, lst_b)
    print(answer)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve( lst_a, lst_b,n):
    if n.count("-")!=1:
        answer= "No"
    else:
        N,NN=n.split("-")
        if lst_a == len(N) and lst_b == len(NN):
            answer = "Yes"
        else:
            answer = "No"
    return answer

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    [str_n, str_i] = line1.split(' ')
    line2 = sys.stdin.readline().rstrip()
    return (int(str_n), int(str_i), line2)

def main():
    n, i, s = readQuestion()
    answer = solve(n, i, s)
    print(answer)
    
if __name__ == '__main__':
    main()
n=int(input())
1/(n>3)

### FIXED CODE ###

n,*a=map(int,open(0).read().split())
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  s={a}
  while a!=p[a]:
    s|={p[a]}
    a//=p[a]
    s|={a}
  for i in s:c[i]+=1
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')
a=input()
print('ABC'　+a)


### FIXED CODE ###

a=input()
b='ABC'
print(b + a)
def listrep(n,m,s):
    tab = [[[0]*(s+1) for j in range(n+1)]
    tab[0][0] = 1
    for i in range(1,n+1):
        for k in range(s+1):
            if i <= k:
                tab[i][k] += tab[i][k-i] + tab[i-1][k-i]
            if j-1 >= m:
                tab[i][k] -= tab[i-1][j-1-m]
    return tab[n][m][s]

while True:
    n,m,s = map(int,input().split())
    if n == 0 : break
    n *= n
    print(listrep(n,m,s))

### FIXED CODE ###

def listrep(n,m,s):
    tab = [[0]*(s+1) for j in range(n+1)]
    tab[0][0] = 1
    for i in range(1,n+1):
        for k in range(s+1):
            if i <= k:
                tab[i][k] += tab[i][k-i] + tab[i-1][k-i]
            if k-1 >= m:
                tab[i][k] -= tab[i-1][k-1-m]
            tab[i][k] %= 100000
    return tab[n][s]

while True:
    n,m,s = map(int,input().split())
    if n == 0 : break
    n *= n
    print(listrep(n,m,s))
T = input()
S = ''
p,q,r,s = 'maerd','esare','remaerd','resare'
for i in range(len(T)):
    S += T[len(T)-i]
while len(S) >= 7:
    x = S[:5]
    y = S[:6]
    z = S[:7]
    if x == p or x == q:
        if len(S) > 5:
            S = S[5:]
        else:
            S = ''
    elif y == s:
        if len(S) > 6:
            S = S[6:]
        else:
            S = ''
    elif z == r:
        if len(S) > 7:
            S = S[7:]
        else:
            S = ''
    else:
        break
ans = 'NO'
if len(S) == 0:
    ans = 'YES'

### FIXED CODE ###

T = input()
S = ''
p,q,r,s = 'maerd','esare','remaerd','resare'
for i in range(len(T)):
    S += T[len(T)-i-1]
while len(S) >= 5:
    x = S[:5]
    y = S[:6]
    z = S[:7]
    if x == p or x == q:
        if len(S) > 5:
            S = S[5:]
        else:
            S = ''
    elif y == s:
        if len(S) > 6:
            S = S[6:]
        else:
            S = ''
    elif z == r:
        if len(S) > 7:
            S = S[7:]
        else:
            S = ''
    else:
        break
ans = 'NO'
if len(S) == 0:
    ans = 'YES'
print(ans)
while True :
    (H, W) = [int(i) for i in input().split()]

    if H == W == 0:
        break

    print('#' * W)
    for a in range(H - 2):
        print('#' + ('.' * (W - 2)) + '#')
    print('#' * W)

??????print()

### FIXED CODE ###

while True:
    (H, W) = [int(i) for i in input().split()]
    
    if H == W == 0 :
        break

    print('#' * W)
    for a in range(H - 2) :
        print('#' + '.' * (W - 2) + '#')
    print('#' * W)
    print()
[a,b,c] = [int(i) for i in input().split(" ")]
goukei = 0
for i in range(1,a+1):
  kurainowa = 0
  kisuu = [int(k) for k in list(str(i))]
  for j in range(0,len(kissu)-1+1):
    kurainowa = kurainowa + kissu[j]
  if kurainowa < b+1 and a-1 <kurainowa :
    goukei = goukei + i
print(goukei)

### FIXED CODE ###

[a,b,c] = [int(i) for i in input().split(" ")]
goukei = 0
for i in range(1,a+1):
  kurainowa = 0
  kisuu = [int(k) for k in list(str(i))]
  
  for j in range(0,len(kisuu)-1+1):
    kurainowa = kurainowa + kisuu[j]
  if kurainowa < c+1 and b-1 <kurainowa :
    goukei = goukei + i
print(goukei)
n=int(input())
a=list(map(int,input().split()))
def findMax(a):
    l=len(a)
    if(l==0):
        return 0
    elif(l==1):
        return 0
    else:
        i=1
        while(i<l):
            if(a[i]>a[i-1]):
                return(max(i-1,findMax(a[i:])))
            i+=1
        return l-1

print(findMax(a))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
startpt=0
indexer=0
maxi=0
i=1
while(i<n):
    if(a[i]>a[i-1]):
        maxi=max(i-startpt-1,maxi)
        startpt=i
        
    i+=1
maxi=max(i-startpt-1,maxi)
print(maxi)
import sys
while True:
    n=0
    s=sys.stdin.readline()
    if s=='0\n': break
    for i in range(len(s)-1):
        n+=int(s[i])
    print(n)

### FIXED CODE ###

input()
print(' '.join(input().split()[::-1]))