Harryxun/stf_run huggingface dataset:
#python3
from collections import deque

def main():
    Qa = deque(input())
    Qb = deque(input())
    Qc = deque(input()) 

    reserve = deque()
    reserve.append('a')

    while len(reserve) != 0:
        v = reserve.popleft()
        if  v == 'a':
            if len(Qa) == 0:
                print('A')
                break
            else:
                reserve.append(Qa.popleft())
        elif v == 'b':
            if len('b') == 0:
                print('B')
                break
            else:
                reserve.append(Qb.popleft())
        elif v == 'c': 
            if len(Qc) == 0:
                print('C')
                break
            else:
                reserve.append(Qc.popleft())
    

main()


### FIXED CODE ###

#python3
from collections import deque

def main():
    Qa = deque(input())
    Qb = deque(input())
    Qc = deque(input()) 

    reserve = deque()
    reserve.append('a')

    while len(reserve) != 0:
        v = reserve.popleft()
        if  v == 'a':
            if len(Qa) == 0:
                print('A')
                break
            else:
                reserve.append(Qa.popleft())
        elif v == 'b':
            if len(Qb) == 0:
                print('B')
                break
            else:
                reserve.append(Qb.popleft())
        elif v == 'c': 
            if len(Qc) == 0:
                print('C')
                break
            else:
                reserve.append(Qc.popleft())
    

main()
N = input()

if N ='ABC':
    print("ARC")
else:
    print("ABC")

### FIXED CODE ###

N = input()

if N == "ABC":
    print("ARC")
else:
    print("ABC")
n,m=map(int,input().split())
if n>m:
  print("No")
else:
  print("Yes)

### FIXED CODE ###

n,m=map(int,input().split())
if n>m:
  print("No")
else:
  print("Yes")
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
PS = [line.split() for line in read().decode('utf8')]
AC = [False] * (N + 1)
WA = [0] * (N + 1)

penal = 0
for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == 'WA':
        WA[p] += 1
    else:
        AC[p] = True
        penal += WA[p]

ac = sum(AC)
print(ac, penal)

### FIXED CODE ###

"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
PS = [line.split() for line in readlines()]
AC = [False] * (N + 1)
WA = [0] * (N + 1)

penal = 0
for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA[p] += 1
    else:
        AC[p] = True
        penal += WA[p]

ac = sum(AC)
print(ac, penal)
a, b, c = (int(i) for i in input().split())
d, e, f = (int(i) for i in input().split())

if a == f and b == e and c == d:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

s1 = input()
s2 = input()

if s1[0] == s2[2] and s1[1] == s2[1] and s1[2] == s2[0]:
  print('YES')
else:
  print('NO')
import numpy as np

N = int(input())
price = []

for i in range(N):
    price.append(int(input()))

price = np.array(price)
max_index = np.argmax(price)

print(int(np.sum(price) - price[max_index] / 2

### FIXED CODE ###

import numpy as np

N = int(input())
price = []

for i in range(N):
    price.append(int(input()))

price = np.array(price)
max_index = np.argmax(price)

print(int(np.sum(price) - price[max_index] / 2))
k = int(input())

ans = 0
for a in range(1, k):
  for b in range(1, k):
    for c in range(1, k):
      ans += gcd(a, b, c)
      
print(ans)

### FIXED CODE ###

import math
k = int(input())

ans = 0
for a in range(1, k+1):
  for b in range(1, k+1):
      m = math.gcd(a, b)
      for c in range(1, k+1):
          ans += math.gcd(m, c)

print(ans)
H,W,M = map(int,input().split())
h = [0]*M
w = [0]*M

from collections import defaultdict
counter_h = defaultdict(int)
counter_w = defaultdict(int)

for i in range(M):
    h[i],w[i] = map(int, input().split())
    counter_h[h[i]] += 1
    counter_w[w[i]] += 1

@njit
def main(counter_h,counter_w,h,w,M):
    MAX_h = max(counter_h.values())
    h_list = [k for k, v in counter_h.items() if v == MAX_h]
    MAX_w = max(counter_w.values())
    w_list = [k for k, v in counter_w.items() if v == MAX_w]

    import itertools

    ans = MAX_h+MAX_w

    if len(h_list)*len(w_list)<=3*10**5:
        X = list(itertools.product(h_list, w_list))


        check = 0


        for i in range(M):
                if (h[i],w[i]) in X:
                    check += 1

        if len(X)==check:
            ans -= 1

    print(ans)
    
main(counter_h,counter_w,h,w,M)

### FIXED CODE ###

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

from collections import defaultdict
counter_h = defaultdict(int)
counter_w = defaultdict(int)

for i in range(M):
    h[i],w[i] = map(int, input().split())
    counter_h[h[i]] += 1
    counter_w[w[i]] += 1

MAX_h = max(counter_h.values())
h_list = [k for k, v in counter_h.items() if v == MAX_h]
MAX_w = max(counter_w.values())
w_list = [k for k, v in counter_w.items() if v == MAX_w]


ans = MAX_h+MAX_w
check = 0

for i in range(M):
    if counter_h[h[i]]==MAX_h and counter_w[w[i]]==MAX_w:
        check += 1

if len(h_list)*len(w_list)==check:
    ans -= 1

print(ans)
n = int(input())
A = list(map(int,input().split()))
A_l = [0,*A[:],0]
D = 0
for i in range(len(A_l) - 1):
  D += abs(A_l[i] - A_l[i + 1])
for i in range(n):
  print(D - abs(A_l[i] - A_l[i + 1])- abs(A_l[i + 1] - A_l[i + 2]) + abs(A_l[i] - A_l[i + 2]))

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
A_l = [0,0]
A_l[1:1] = A
D = 0
for i in range(len(A_l) - 1):
  D += abs(A_l[i] - A_l[i + 1])
for i in range(n):
  print(D - abs(A_l[i] - A_l[i + 1])- abs(A_l[i + 1] - A_l[i + 2]) + abs(A_l[i] - A_l[i + 2]))
import sys
sys.setrecursionlimit(10**8)
N = int(input())
n=int(input())
c=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  c[a].append((b,i))
  c[b].append((a,i))

ans=[0]*(n-1)
g=[0]*n
def dfs(v,h=-1):
  res=1
  for i,j in c[v]:
      if g[i]:
            continue
      g[v]=1
      if h==res:
            res+=1
      ans[j]=res
      dfs(i,res)
      res+=1

dfs(0)
print(max(ans))
for i in ans:
      print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
for i,(a,b) in enumerate(AB):
    a,b = a-1,b-1
    es[a].append((b,i))
    es[b].append((a,i))
ans=[0]*(N-1)
g=[0]*N
def dfs(v,h=-1):
  res=1
  for i,j in es[v]:
      if g[i]:
            continue
      g[v]=1
      if h==res:
            res+=1
      ans[j]=res
      dfs(i,res)
      res+=1

dfs(0)
print(max(ans))
for i in ans:
      print(i)
maxnum = 10001

# エラトステネスのふるい
is_prime = [x for x in range(maxnum)]
for prime in is_prime:
    if prime == 0 or prime == 1:
        is_prime[prime] = 0
        continue
    for non_prime in range(prime * 2, maxnum, prime):
        is_prime[non_prime] = 0

is_like = [False] * maxnum
for i in range(maxnum):
    if (is_prime[i] and is_prime[(i + 1) // 2]):
        is_like[i] =  True

like_sum = [0] * maxnum
for i in range(1, maxnum):
    like_sum[i] = like_sum[i - 1]
    if (is_like[i]):
        like_sum[i] += 1

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(like_sum[r] - like_sum[l - 1])


### FIXED CODE ###

maxnum = 100000

# エラトステネスのふるい
is_prime = [x for x in range(maxnum)]
for prime in is_prime:
    if prime == 0 or prime == 1:
        is_prime[prime] = 0
        continue
    for non_prime in range(prime * 2, maxnum, prime):
        is_prime[non_prime] = 0

is_like = [False] * maxnum
for i in range(maxnum):
    if (is_prime[i] and is_prime[(i + 1) // 2]):
        is_like[i] =  True

like_sum = [0] * maxnum
for i in range(3, maxnum):
    like_sum[i] = like_sum[i - 1]
    if (is_like[i]):
        like_sum[i] += 1

q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(like_sum[r] - like_sum[l - 1])
n=int(input())
d=0

for i in range(n):
    s,p=input().split()
    d.append(s,int(100-p),i)

d.sort()
for i in range(n):
    print(d[i][2])

### FIXED CODE ###

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

for i in range(n):
    s,p=input().split()
    d.append((s,100-int(p),i+1))

d.sort()
for i in range(n):
    print(d[i][2])
x,y=map(int,input().split())
print('YES'if y%2==0 and x*2<=y<=x*4)

### FIXED CODE ###

x,y=map(int,input().split())
print('Yes'if y%2==0 and x*2<=y<=x*4else'No')
P,Q,R = map(int,input().split(' '))
List = [P,Q,R].sort()
print(List[0]+List[1])

### FIXED CODE ###

List = list(map(int,input().split(' ')))
List.sort()
print(sum(List[0:2]))
import math
n = int(input())
a = list(map(int,input().split()))
least_common_multiple = 1
for i in range(n):
    least_common_multiple = int(least_common_multiple*a[i]/math.gcd(least_common_multiple,a[i]))
ans = 0
for i in range(n):
    ans += (least_common_multiple-1)%a[i]
print(ans)

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))-1
print(a.sum())
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i,ai in enumerate(a):
  if (i+1)%2 == 1 and ai%2 == 1:
    ans += 1
print(ans)

### FIXED CODE ###

l,r,d = map(int,input().split())
print(r//d-(l-1)//d)
H, N = map(int, input().split())
number = int(input())
S = sum(number)
if S / N >= H / N:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A) >= H:
  print("Yes")
else:
  print("No")
a = int(input())
b = int(input())
 
s = 16
for i in range(16):
	if i%2 == 0:
		if a > 0:
			s -= 1
			a -= 1
	else:
		if b > 0:
			s -= 1
			b -= 1
	if s < 0:
		break
 
if a > 0 or b > 0:
	print(':(')
else:
	print('Yay!')

### FIXED CODE ###

a, b = list(map(int, input().split()))
 
s = 16
for i in range(16):
	if i%2 == 0:
		if a > 0:
			s -= 1
			a -= 1
	else:
		if b > 0:
			s -= 1
			b -= 1
	if s < 0:
		break
 
if a > 0 or b > 0:
	print(':(')
else:
	print('Yay!')
height = []
for i in range(10)
    height.append(int(input()))
height.sort()
for i in range(9,6,-1)
    print(height[i])

### FIXED CODE ###

a = []
for i in range(10):
    a.append(int(input()))
a.sort()
print(a[9])
print(a[8])
print(a[7])
N = int(input())
A = list(map(int, input().split()))
 
mod = int(1e+9 + 7)
L = [0, 0, 0]
pi = 1
for i in range(N):
  j = 0
  while L[j] != A[i]:
    j += 1
    if j == 3:
      break
  n = 0
  for k in range(3):
    if L[k] == A[i]:
      n += 1
  if j != 3:
    L[j] += 1
  pi *= n
  pi %= mod
print(pi)

### FIXED CODE ###

# -*- coding: utf-8 -*-
m_1, d_1 = map(int, input().split())
m_2, d_2 = map(int, input().split())

if m_1 == m_2:
  print(0)
else:
  print(1)
n = int(input())
a = list(map(int, input().split()))

with open('testcase_12.in') as f:
    n = int(f.readline())
    a = list(map(int, f.readline().split()))

b = [-1] * n
for i in range(n, 0, -1):
    cnt = sum(b[j - 1] for j in range(i + i, n + 1, i))
    b[i - 1] = int(a[i - 1] != cnt % 2)

print(sum(b))
if sum(b) > 0:
    print(*[i + 1 for i in range(n) if b[i] == 1])


### FIXED CODE ###

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

b = [-1] * n
for i in range(n, 0, -1):
    cnt = sum(b[j - 1] for j in range(i + i, n + 1, i))
    b[i - 1] = int(a[i - 1] != cnt % 2)

print(sum(b))
if sum(b) > 0:
    print(*[i + 1 for i in range(n) if b[i] == 1])
import math
N = int(input())
n = 45

x = [None] * N
y = [None] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 0
for i in range(n):
    theta = (2 * math.pi / n) * i
    c = math.cos(theta)
    s = math.sin(theta)
    tmp_x = 0
    tmp_y = 0
    for j in range(N):
        if x[j] * c + y[j] * s > 0:
            tmp_x += x[j]
            tmp_y += y[j]
    if tmp_x**2 + tmp_y**2 > ans**2:
        ans = math.sqrt(tmp_x**2 + tmp_y**2)

print(ans)


### FIXED CODE ###

s = input()
t = input()

ans = 0

for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)
a = int(input())
if a % 1 == 0 or a % 2 == 0 or a % 3 == 0 or a % 4 == 0 or a % 5 == 0 or a % 6 == 0 or a % 7 == 0 or a % 8 == 0 or a % 9 == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a, b = map(int, input().split())
if a < 10 and b < 10:
  print(a * b)
else:
  print('-1')
def koch(n, a_x, a_y, b_x, b_y):
  if n == 0:
    return
 
  th = math.pi*60.0/180.0
 
  s_x = (2.0*a_x + 1.0*b_x)/3.0
  s_y = (2.0*a_x + 1.0*b_x)/3.0
  t_x = (1.0*a_x + 2.0*b_x)/3.0
  t_y = (1.0*a_x + 2.0*b_x)/3.0
  u_x = (t_x - s_x)*math.cos(th) + (t_y - s_y)*math.sin(th) + s_x
  u_y = (t_x - s_x)*math.sin(th) + (t_y - s_y)*math.cos(th) + s_y
 
  koch(n-1, a_x, a_y, s_x, s_y)
  print '%.8f %8.f' % (s_x, s_y)
  koch(n-1, s_x, s_y, u_x, u_y)
  print '%.8f %8.f' % (u_x, u_y)
  koch(n-1, u_x, u_y, t_x, t_y)
  print '%.8f %8.f' % (t_x, t_y)
  koch(n-1, t_x, t_y, b_x, b_y)
 
 

n = input()
a_x = 0.0
a_y = 0.0
b_x = 100.0
b_y = 0.0
 
print '%.8f %8.f' % (a_x, a_y)
koch(n, a_x, a_y, b_x, b_y)
print '%.8f %8.f' % (b_x, b_y)

### FIXED CODE ###

def koch(n, a_x, a_y, b_x, b_y):
  if n == 0:
    return
 
  th = math.pi*60.0/180.0
 
  s_x = (2.0*a_x + 1.0*b_x)/3.0
  s_y = (2.0*a_y + 1.0*b_y)/3.0
  t_x = (1.0*a_x + 2.0*b_x)/3.0
  t_y = (1.0*a_y + 2.0*b_y)/3.0
  u_x = (t_x - s_x)*math.cos(th) - (t_y - s_y)*math.sin(th) + s_x
  u_y = (t_x - s_x)*math.sin(th) + (t_y - s_y)*math.cos(th) + s_y
 
  koch(n-1, a_x, a_y, s_x, s_y)
  print '%.8f %.8f' % (s_x, s_y)
  koch(n-1, s_x, s_y, u_x, u_y)
  print '%.8f %.8f' % (u_x, u_y)
  koch(n-1, u_x, u_y, t_x, t_y)
  print '%.8f %.8f' % (t_x, t_y)
  koch(n-1, t_x, t_y, b_x, b_y)
 
 

import math
n = input()
a_x = 0.0
a_y = 0.0
b_x = 100.0
b_y = 0.0
 
print '%.8f %.8f' % (a_x, a_y)
koch(n, a_x, a_y, b_x, b_y)
print '%.8f %.8f' % (b_x, b_y)
N,K = list(map(int,input().split()))
B = []
ans = 0
for i in range(K):
    d = input()
    A = list(map(int,input().split()))
    for l in range(len(A)):
      B.append(A[l])
for j in range(1,N+1):
    if j not in B:
        ans += 1
print(ans)

### FIXED CODE ###

S = input()
if S == 'ABC':
    print('ARC')
else:
    print('ABC')
import sys
input = sys.stdin.readline

nums = list(map(int, list(input().rstrip('\r'))))
ans_op = [''] * 3
for bit in range(2**3):
    total = 0
    tmp = [''] * 3
    for i in range(3):
        if i == 0:
            total += nums[i]
        if (bit >> i) & 1:
            total += nums[i+1]
            tmp[i] = '+'
        else:
            total -= nums[i+1]
            tmp[i] = '-'
    if total == 7:
       ans_op = tmp
       break
ans = ''
for i in range(3):
    if i == 0:
        ans += (str(nums[i]))
    ans += (ans_op[i] + str(nums[i+1]))
ans += '=7'
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

nums = list(map(int, list(input().rstrip('\r\n'))))
ans_op = [''] * 3
for bit in range(2**3):
    total = 0
    tmp = [''] * 3
    for i in range(3):
        if i == 0:
            total += nums[i]
        if (bit >> i) & 1:
            total += nums[i+1]
            tmp[i] = '+'
        else:
            total -= nums[i+1]
            tmp[i] = '-'
    if total == 7:
       ans_op = tmp
       break
ans = ''
for i in range(3):
    if i == 0:
        ans += (str(nums[i]))
    ans += (ans_op[i] + str(nums[i+1]))
ans += '=7'
print(ans)
import math
a,b,c=map(int,input().split())
if math.sqrt(a)+math.sqrt(b)+10**(-7)<math.sqrt(c):
	print('Yes')
else:
	print('No')  

### FIXED CODE ###

k = int(input())
x = [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]
print(x[k-1])
count = 0
while True:
    x=raw_input()
    count + =1
    if x == '0':
      break
    print('Case' + count + ':' + x)  

    
    

### FIXED CODE ###

count = 0
while True:
    x=raw_input()
    count += 1
    if x == '0':
      break
    print('Case ' + str(count) + ': ' + x)
a,b,k = map(int, input().split())

min_val  = min(a,b)
list = []
for i in range(min_val,0,-1):
  if a%(i+1) == 0 and b%(i+1) == 0:
    list.append(i+1)
    
print(list[k-1])

### FIXED CODE ###

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

min_val  = min(a,b)
t = 0
for i in range(min_val,0,-1):
  if a%(i) == 0 and b%(i) == 0:
    t += 1
  if t == k:
    print(i)
    break
n=int(input())
s=[0]*100
for i in range(1,10):
  for j in range(1,10):
    s[10*i+j]=i*j
p=81
for k in range(1,101):
  if s[k]==n:
    p=p-1
if p==81:
  print('No')
else:
  print('Yes')


### FIXED CODE ###

n=int(input())
s=[0]*100
for i in range(1,10):
  for j in range(1,10):
    s[10*i+j]=i*j
p=81
for k in range(0,100):
  if s[k]==n:
    p=p-1
if p==81:
  print('No')
else:
  print('Yes')
n=str(N)
if n.find("7")!= -1:
   print("Yes")
else:
   print("No")

### FIXED CODE ###

n=str(input())
if n.find("7")!= -1:
   print("Yes")
else:
   print("No")
s,t=input().split()
a,b=(int,input().split())
u=input()

if s==u:
  print (a-1,b)
elif t==u:
  print(a,b-1)


### FIXED CODE ###

s,t=input().split()
a,b=map(int,input().split())
u=input()

if s==u:
  print (a-1,b)
elif t==u:
  print(a,b-1)
import rs
li = input()
flag = 'No'

if re.match("^(dream|dreamer|erase|eraser)+$", li):
  flag = 'YES'
      
  
print(flag)

### FIXED CODE ###

import re
S = input()
'''
メタ文字：
^ = 文字列の先頭、
| = OR
+ = 直前のパターンを1回以上繰り返し、
$ = 文字列の末尾
'''
if re.match("^(dream|dreamer|erase|eraser)+$", S):
    print('YES')
else:
    print('NO')
n=int(input())

t,x,y=map(int,input().split())
num=x+y

if t%num!=0:
  print("No")
  exit()
if n==1:
  print("Yes")
  exit()

for i in range(n-1):
  t,x,y=map(int,input().split())
  num-=(x+y)
  num=abs(num)
  if t%num!=0:
    print("No")
    exit()
    
print("Yes")
  

### FIXED CODE ###

n=int(input())

num,a,b=0,0,0

for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num>=su and num%2 == su%2:
    ans="Yes"
  else:
    ans="No"
    break
      
print(ans)
N, H = map(int, input().split())
a_list = []
b_list = []
for i in range(N):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
count = 0
a = max(a_list)
b_list.sort()
while True:
    if len(b_list) >= 1:
        if b_list[-1] >= a:
            b = b_list.pop(-1)
            H -= b
            count += 1
            if H <= 0:
                break
        else:
            H -= a
            count += 1
            if H <= 0:
                break
    else:
        H -= a
        count += 1
        if H <= 0:
            break
        
print(count)

### FIXED CODE ###

S = input()
print(S.replace("2017", "2018"))
a=(int(input())-2)%13
b=(int(input())-2)%13
print(["Draw","Bob","Alice"][((a==b)+1)*((a<b)-(b<a))])

### FIXED CODE ###

a,b=map(int,input().split())
if a==1:a=14
if b==1:b=14
if a>b:
    print("Alice")
elif a==b:
    print("Draw")
else:
    print("Bob")
A,B=map(int, input().split())
C=list(int(input()))
count= 0
for i in range (B):
	count=count+C[i]
if count<=A:
	print("Yes")
else: print("No")

### FIXED CODE ###

A,B=map(int,input().split())
C=list(input().split())
count= 0
for i in range (B):
	count=count+int(C[i])
if count>=A:
	print("Yes")
else: print("No")
a=ord(list(input()));print('YNeos'[a[0]^a[1]^a[2]==96::2])

### FIXED CODE ###

print("YNeos"[len(set(input()))<3::2])
h,w=map(int,input().split())
a=[list(input().split()) for _ in range(h)]

#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print(" ".join(tmpl))

### FIXED CODE ###

h,w=map(int,input().split())
a=[]
for _ in range(h):
	b=[]
	s=input()
	for i in range(w):
		b.append(s[i])
	a.append(b)
	
#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print("".join(tmpl))		#listを詰めて表示
spam=input().split(' ')
print(' '.join(spam[0] * spam[1], 2*(spam[0]+spam[1])))
return 0

### FIXED CODE ###

z= input()
x, y = z.split()
 
m = int(x)*int(y)
l = int(x)*2+int(y)*2
print('{} {}'.format(m,l))
N = int(input().strip())

l = [_ for _ in int(input().strip())]

count = 0

while all([a == 0 for a in list(map(lambda x: x%2, l))]):
    l = list(map(lambda x: x/2, l))
    count += 1

print(count)

### FIXED CODE ###

N = int(input())
 
l = list(map(int, input().strip().split()))
 
count = 0
 
while all([a == 0 for a in list(map(lambda x: x%2, l))]):
    l = list(map(lambda x: x/2, l))
    count += 1
    
print(count)
k =int(input())
a, b = map(int, input().split())
 
for i in range(a, b):
    if (i % k == 0):
        break
    j = i % k 
if(j == 0):
    print("OK")
else:
    print("NG")

### FIXED CODE ###

k =int(input())
a, b = map(int, input().split())
 
for i in range(a, b+1):
    if (i % k == 0):
        print("OK")
        break
else:
    print("NG")
N = int(input())
L = [int(input()) for L in range(N-1)]
if max(L) < (sum(L) - max(L)):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
if max(L) < (sum(L) - max(L)):
    print('Yes')
else:
    print('No')
x,a,b = map(int,input().split())

if b < a:
  print('delicious')
elif b <= x:
  pritn('safe')
elif b > x:
  print('dangerous')

### FIXED CODE ###

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

if a>=b:
  print('delicious')
elif b - a < x + 1:
  print('safe')
else:
  print('dangerous')
n = int(input())
csf = []
for i in range(n):
    csf.append(list(map(int,input().split())))


for i in range(n-1):
    time = 0
    for j in  range(i,n-1):
        if time < csf[j][1]:
            time = csf[j][0] + csf[j][1]
        else:
            tmp = (time-csf[j][1])%csf[j][2] +csf[j][0]
            time += tmp
    print(time)

print('0')

### FIXED CODE ###

n = int(input())
csf = []
for i in range(n-1):
    csf.append(list(map(int,input().split())))


for i in range(n-1):
    time = 0
    for j in  range(i,n-1):
        if time <= csf[j][1]:
            time = csf[j][0] + csf[j][1]
        else:
            tmp = -time%csf[j][2] +csf[j][0]
            time += tmp
    print(time)

print('0')
from itertools import permutations as P
import sys
r=sys.stdin.readline
for e in iter(r,'0'):
 n,k=int(e),int(r())
 C=[r()for _ in[0]*n]
 print(len(set(''.join(s)for s in P(C,k))))


### FIXED CODE ###

def s():
 from itertools import permutations as P
 for e in iter(input,'0'):
  n,k=int(e),int(input())
  C=[input()for _ in[0]*n]
  print(len(set(''.join(s)for s in P(C,k))))
if'__main__'==__name__:s()
n = int(input())
s=int(n**0.5)
list=[]
for i in range(1,s):
    if n%i==0:
        list.append(int(i+ n/i -2))
print(min(list))


### FIXED CODE ###

n = int(input())
s=int(n**0.5)
list=[]
for i in range(1,s+1):
    if n%i==0:
        list.append(int(i+ n/i -2))
print(min(list))
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

l = 0
r = max(a * f for a, f in zip(A, F)) + 1

while l < r:
    m = (l + r) // 2
    if sum(max(a - m // f, 0) for a, f in zip(A, F)) <= K:
        r = m
    else:
        l = m + 1

print(r)

### FIXED CODE ###

A, B = map(int, input().split())
if A > 9 or B > 9:
    print(-1)
else:
    print(A * B)
n=int(input())
v=list(map(int, input().split()))
v.sort()
sum=v[0]
for i in range(1,len(v))
	sum=(sum+v[i])/2
print(sum)

### FIXED CODE ###

n=int(input())
v=list(map(int, input().split()))
v.sort()
sum=v[0]
for i in range(1,len(v)):
	sum=(sum+v[i])/2
print(sum)
n = int(input())

ans = 0
for i in range(1, n+1):
    tmp = 0
    for j in range(1, i/2+1):
        if n % j == 0:
            tep += 1

    if tmp == 8:
        ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, N+1):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    ans += 1
print(ans)