Harryxun/stf_run huggingface dataset:
def main():
    while True:
        n=int(raw_input())
        if n==0:    break;
        solve(n)
def solve(n):
    a=[]
    for _ in range(n):
        tmp=map(int,raw_input().split(" "))
        a.append(Pair(tmp[0],tmp[1]+tmp[2]))
    a.sort()
    print a[-1].x, a[-1].y
class Pair:
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __cmp__(self,a):
        return self.y-a.y
if __name__=="__main__":    main()

### FIXED CODE ###

import sys
def main():
    while True:
        ipt=raw_input()
        if str.isdigit(ipt):
            n=int(ipt)
            if n==0:    break;
            solve(n)
        else:
            sys.stderr.write(ipt)
def solve(n):
    a=[]
    for _ in range(n):
        tmp=map(int,raw_input().split(" "))
        a.append(Pair(tmp[0],tmp[1]+tmp[2]))
    a.sort()
    print a[-1].x, a[-1].y
class Pair:
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def __cmp__(self,a):
        return self.y-a.y
if __name__=="__main__":    main()
from itertools import accumulate


class CoeffTable:
    def __init__(self, n):
        self.n = n
        if n == 2:
            (self.p2, self.p1, self.m1, self.m2) = (0, 1, 1, 0)
        if n % 2 == 0:
            self.p1 = self.m1 = 1
            self.p2 = self.m2 = (n - 1) // 2
        else:
            self.p1 = 0
            self.m1 = 2
            self.p2 = (n - 1) // 2
            self.m2 = (n - 2) // 2
    def reverse(self):
        (self.p2, self.p1, self.m1, self.m2) = (
            self.m2,
            self.m1,
            self.p1,
            self.p2,
        )

    def cumsum(self):
        return list(accumulate([self.p2, self.p1, self.m1, self.m2]))



def main(n, seq):
    seq = sorted(seq, reverse=True)
    coeff = CoeffTable(n)
    cm = coeff.cumsum()
    ans1 = (
        2 * sum(seq[0 : cm[0]])
        + 1 * sum(seq[cm[0] : cm[1]])
        - 1 * sum(seq[cm[1] : cm[2]])
        - 2 * sum(seq[cm[2] : cm[3]])
    )
    coeff.reverse()
    rcm = coeff.cumsum()
    ans2 = (
        2 * sum(seq[0 : rcm[0]])
        + 1 * sum(seq[rcm[0] : rcm[1]])
        - 1 * sum(seq[rcm[1] : rcm[2]])
        - 2 * sum(seq[rcm[2] : rcm[3]])
    )
    ans = max(ans1, ans2)
    print(ans)
    return


if __name__ == "__main__":
    n = int(input())
    sample = []
    for _ in range(n):
        sample.append(int(input()))
    main(n, sample)


### FIXED CODE ###

def main(string):
    if len(string) == 2:
        return string
    elif len(string) == 3:
        return string[::-1]

if __name__ == '__main__':
    s = input()
    print(main(s))
N = int(input())　
if N <1000:
	print('ABC') 
else:
	print('ABD') 
	

### FIXED CODE ###

N = int(input())
if N <1000:
	print("ABC")
else:
	print("ABD")
d,t,s = map(int,input().split())

print("Yes" if s*t >= d else "No)

### FIXED CODE ###

d,t,s = map(int,input().split())
if s*t >= d:
    print("Yes")
else:
    print("No")
def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n):
        for a, b, c in ABC:
            if distance[a - 1] is not None and \
                (distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c):
                distance[b - 1] = distance[a - 1] + c

    for a, b, c in ABC:
        if distance[b - 1] < distance[a - 1] + c:
            return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))


### FIXED CODE ###

def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None:
                continue
            if distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None or distance[b - 1] is None:
                continue
            if distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c
                if b == n:
                    return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))

### FIXED CODE ###

#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)
if len(l) >= 2:
    for i in range(len(l)-1):
        ans = []
        for cx in range(101):
            for cy in range(101):
                if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy) and l[i][2] != 0 and l[i+1][2] != 0:
                    if i == 0:
                        ans.append([cx, cy])
                    else:
                        if [cx, cy] in ansn:
                            ans.append([cx, cy])
        ansn = ans[:]
        if len(ans) == 1:
            break
    print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))
else:
    print(l[0][0], l[0][1], l[0][2])
n, m = map(int, input().split())
ship = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == n:
        ship.append((a, b))
if len(ship) == 0:
    print("IMPOSSIBLE")
    exit()

ship.sort()
i = 0

while ship[i][0] == 1:
    i += 1
if i == len(ship):
    print("IMPOSSIBLE")
    

for j in range(i):
    for k in range(i, len(ship)):
        if ship[j][1] == ship[k][0]:
            print("POSSIBLE")
            exit()
        elif ship[j][1] < ship[k][0]
            break

print("IMPOSSIBLE")


### FIXED CODE ###

n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
i=0
while(d<=x):
  d+=l[i]
  i+=1;
print(i)

### FIXED CODE ###

n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
i=1
while i<=n:
  d+=l[i-1]
  if x<d:
    break
  i+=1
print(i)
n= int(input())
D=list(map(int,input().split()))

m=int(input())
T=list(map(int,input().split()))

cnt=[0]*1000000010

for i in range(n):
    cnt[D[i]]+=1

ans="YES"
for i in range(m):
    cnt[T[i]]-=1
    if cnt[T[i]]<0:
        ans="NO"
        break

print(ans)


### FIXED CODE ###

from collections import defaultdict
n= int(input())
D=list(map(int,input().split()))

m=int(input())
T=list(map(int,input().split()))

dicta=defaultdict(lambda:0)
dictb=defaultdict(lambda:0)

for i in range(n):
    dicta[D[i]]+=1

for i in range(m):
    dictb[T[i]]+=1


ans="YES"
for i in range(m):
    if dicta[T[i]]<dictb[T[i]]:
        ans="NO"
        break

print(ans)
s = open('input', 'r').read()
prev = s[0]
ans = 0

for c in s:
    if c != prev:
        ans += 1
        prev = c
print(ans-1)


### FIXED CODE ###

s = input()
prev = s[0]
ans = 0

for c in s:
    if c != prev:
        ans += 1
        prev = c
print(ans)
n,a=open(0)
*a,=map(int,a.split())
c,d={},{}
m=0
for j,i in enumerate(a):
  if i>m:d[i],m=j,i
  c[i]=c.get(i,0)+1
i=sorted(d)[::-1]
a=[0]*int(n)
for i,j in zip(i,i[1:]):
  a[d[i]]=(i-j)*c[i]
  c[j]+=c[i]
a[d[j]]=j*c[j]
print(*a)

### FIXED CODE ###

e=enumerate
n,a=open(0)
a=sorted((int(i),j)for j,i in e(('0 '+a).split()))[::-1]
c=[0]*int(n)
t=10**18
for k,(i,j)in e(a[:-1],1):
  t=min(t,j)
  c[t-1]+=(i-a[k][0])*k
print(*c)
a=raw_input()
sp=min(a.count("J"),a.count("I"),a.count("O"))
for k in range(sp,0,-1):
	joi="J"*k+"O"*k+"I"*k
	if joi in a:
		print k
		break
else:
	print 0

### FIXED CODE ###

a=raw_input()
l=len(a)
i=ans=0
while i<l:
	lenj=leno=leni=0
	while i<l and a[i]=="J":
		lenj+=1
		i+=1
	while i<l and a[i]=="O":
		leno+=1
		i+=1
	while i<l and a[i]=="I":
		leni+=1
		i+=1
	if lenj>=leno and leni>=leno:
		ans=max(ans,leno)
print ans
X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
 else:
     sum = 0   
print(sum)

### FIXED CODE ###

X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
else:
     sum = 0   
print(sum)
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

ans = [0]*n
judge_s = 0
judge_c = 0
sc = sorted(sc)

if m == 0:
    if n == 1:
        ans = 0
    else:
        ans = 10**(n-1)
else:
    for i in range(m):
        if judge_s == sc[i][0] and judge_c != sc[i][1]:
            ans = -1
            break
        if n != 1 and sc[i] == [1,0]
            ans = -1
            break
        judge_s = sc[i][0]
        judge_c = sc[i][1]
        ans[sc[i][0]-1] = sc[i][1]


    if ans != -1:
        ans_ = ans.copy()
        ans = 0
        for i in range(n):
            ans += ans_[i]*10**(n-i-1)
        
        if ans_[0] == 0 and n != 1:
            ans += 10**(n-1)
            
    
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

ans = [0]*n
judge_s = 0
judge_c = 0
sc = sorted(sc)

if m == 0:
    if n == 1:
        ans = 0
    else:
        ans = 10**(n-1)
else:
    for i in range(m):
        if judge_s == sc[i][0] and judge_c != sc[i][1]:
            ans = -1
            break
        if n != 1 and sc[i] == [1,0]:
            ans = -1
            break
        judge_s = sc[i][0]
        judge_c = sc[i][1]
        ans[sc[i][0]-1] = sc[i][1]


    if ans != -1:
        ans_ = ans.copy()
        ans = 0
        for i in range(n):
            ans += ans_[i]*10**(n-i-1)
        
        if ans_[0] == 0 and n != 1:
            ans += 10**(n-1)
            
    
print(ans)
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,_ = LI()
    N0 = 2 ** N.bit_length()
    st = [0] * (N0*2)

    def add(p,x):
        p += N0-1
        st[p] = x
        while p > 0:
            p = (p-1) // 2
            st[p] = max(st[p*2+1],st[p*2+2])

    def get(a,b,x,l,r):
        if a <= l and r <= b: return st[x]
        if a >= r or b <= l: return 0
        vl = get(a,b,x*2+1,l,(l+r)//2)
        vr = get(a,b,x*2+2,(l+r)//2,r)
        return max(vl,vr)
    
    A = []
    for a in enumerate(sys.stdin.readline().split()):
        a = int(a)
        A.append(a)
        add(e+1,a)
    max_a = -1
    max_cnt = 0
    for i in range(1,N):
        a = get(i+1,N+1,0,0,N0) - A[i-1]
        if a > max_a:
            max_a = a; max_cnt = 1
        elif a == max_a:
            max_cnt += 1

    print(max_cnt)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,_ = LI()
    N0 = 2 ** N.bit_length()
    st = [0] * (N0*2)

    def add(p,x):
        p += N0-1
        st[p] = x
        while p > 0:
            p = (p-1) // 2
            st[p] = max(st[p*2+1],st[p*2+2])

    def get(a,b,x,l,r):
        if a <= l and r <= b: return st[x]
        if a >= r or b <= l: return 0
        vl = get(a,b,x*2+1,l,(l+r)//2)
        vr = get(a,b,x*2+2,(l+r)//2,r)
        return max(vl,vr)
    A = LI()
    for e,a in enumerate(A):
        add(e+1,a)
    max_a = -1
    max_cnt = 0
    for i in range(1,N):
        a = get(i+1,N+1,0,0,N0) - A[i-1]
        if a > max_a:
            max_a = a; max_cnt = 1
        elif a == max_a:
            max_cnt += 1

    print(max_cnt)


if __name__ == '__main__':
    main()
a,b=map(int,input.split())

c=a*b

if c%2==0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

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


if (a*b)%2==0:
    print("Even")
else:
    print("Odd")
n = int(input())
a = list(map(int, input().split()))

a.sort()
count = 0


def binary_search(numbers, target_number):
    # 最小値を仮決め
    low = 0
    # 範囲内の最大値
    high = len(numbers)


    # 目的地を探し出すまでループ
    while low <= high:
        if low == high:
            return low
        # 中央値を求める（index）
        middle = (low + high) // 2
        # 中央値のnumbersの値とtarget_numberが等しい場合
        if numbers[middle] == target_number:
            return middle
        # 中央値のnumbersの値がtarget_numberより小さい場合
        elif numbers[middle] < target_number:
            low = middle + 1
        # 中央値のnumbersの値がtarget_numberより大きい場合
        else:
            high = middle - 1


for i in range(n-2):
    for j in range(i+1, n-1):
        if a[i] + a[j] > max(a):
            count += n - (j+1)
            continue
        index = binary_search(a, (a[i]+a[j]))
        if a[i] + a[j] == a[index]:
            count += (index-(j+1))
        else:
            count += (index - j)


print(count)



### FIXED CODE ###

from bisect import bisect_left

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


a.sort()
count = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        x = bisect_left(a, a[i] + a[j])
        count += x - (j+1)

print(count)
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K > 3
 
print(114514)

### FIXED CODE ###

input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input() # 無視

equalized = 1
i = 0
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(str(i))
N = int(input())
S = []
for i in range(N):
  Si = str(input())
  S.append(Si) 
  
M = int(input())
T = []
for i in range(M):
  Ti = str(input())
  T.append(Ti)

total = 0
tokuten_list = []
tokuten = []
for i in range(N):
  if not S[i] in T:
    if not S[i] in tokuten_list:
      tokuten_list.append(S[i])
      tokuten.append(1)
    else:
      tokuten[tokuten_list.index(S[i])] = tokuten[tokuten_list.index(S[i])] + 1

print(max(tokuten))

### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
  Si = str(input())
  S.append(Si) 
  
M = int(input())
T = []
for i in range(M):
  Ti = str(input())
  T.append(Ti)

max_point = 0
for i in range(N):
  point = len([1 for s in S if s==S[i]]) - len([1 for t in T if t==S[i]])
  max_point = max([max_point,point])
  
print(max_point)
a,b = map(int, input().split())
print str(min(a**b, b**a))

### FIXED CODE ###

a,b = map(int, input().split())
if a < b:
  print(str(a) * b)
else:
  print(str(b) * a)
import math
maped = map(int, raw_input().split())
r = maped[0]
area = r*r*math.pi
length = 2*r*math.pi
print "%f %f"%(area, length)

### FIXED CODE ###

from math import pi
r, = map(float, raw_input().split())
area = r**2*pi
length = 2*r*pi
print "%f %f"%(area, length)
S=input()
T=input()
s=len(S)
t=len(T)
dp=[['' for i in range(s+1)] for j in range(t+1)]
for i in range(s):
    for j in range(t):
        if S[i]==T[j]:
            dp[i+1][j+1]=dp[i][j]+S[i]
        else:
            dp[i+1][j+1]=dp[i+1][j]
            if len(dp[i][j+1])>len(dp[i+1][j]):
                dp[i+1][j+1]=dp[i][j+1]
print(dp[s][t])


### FIXED CODE ###

S=input()
T=input()
dp=[[0 for j in range(len(T)+1)] for i in range(len(S)+1)]
for i in range(len(S)):
    for j in range(len(T)):
        if S[i]==T[j]:
            dp[i+1][j+1]=dp[i][j]+1
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j])
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1])
i=len(S)
j=len(T)
ans=""
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans=S[i-1]+ans
        i-=1
        j-=1
print(ans)
s=list(map(int,input())
s.sort()
print(s[2]-s[0])


### FIXED CODE ###

s=list(map(int,input().split()))
s.sort()
print(s[2]-s[0])
import math
 
A, B, H, M = map(int, input().split())
 
deg_long = M * 6
deg_short = 30 * H + M / 2
    
rad = math.radians( min(deg_long - deg_short, 360-(deg_long-deg_short)))
print( math.sqrt(A **2 + B ** 2 - 2*A*B*cos(rad)) )

### FIXED CODE ###

import math
 
A, B, H, M = map(int, input().split())
 
deg_long = M * 6
deg_short = 30 * H + M / 2
    
rad = math.radians( min(deg_long - deg_short, 360-(deg_long-deg_short)))
print( math.sqrt(A **2 + B ** 2 - 2* A * B* math.cos(rad)) )
_=int(input())
print('Yes' if sum(list(map(int,input().split()))<=sum(list(map(int,input().split()))) else 'No')

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sorted([a[i]-b[i] for i in range(N)])
k=-sum(c)
# print(c,k)
cp=[ci for ci in c if ci>0]
cn=[ci for ci in c if ci<0]

# 必要な「1増やす回数」
p=sum(cp)+sum([cni%2 for cni in cn])
# 必要な「2減らす回数」
n=sum([(-cni+1)//2 for cni in cn])

f=k>=0 and p<=k and n<=k

print('Yes' if f else 'No')
N, K = map(int, input().split())
S = list(input())

nums = []
now = 1
count = 0
for i in range(len(S)):
    if S[i] == str(now):
        count += 1
    else:
        nums.append(count)
        now = 1 - now
        count = 1
if count != 0:
    nums.append(count)
if len(nums) % 2 == 0:
    nums.append(0)  # ? 1を足すのでは？？

add = 2 * k + 1

sum = []
sum.append(0)
for i in range(len(nums) + 1):
    sum[i+1] = sum[i] + nums[i]

ans = 0

for i in range(len(nums) / 2):
    left = i
    right = min(i + add, len(nums))
    tmp = sum[right] - sum[left]
    ans = max(tmp, ans)

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())

nums = []
now = 1
count = 0
for i in range(len(S)):
    if S[i] == str(now):
        count += 1
    else:
        nums.append(count)
        now = 1 - now
        count = 1
if count != 0:
    nums.append(count)
if len(nums) % 2 == 0:
    nums.append(0)

add = 2 * K + 1

sum = [0] * (len(nums)+1)

for i in range(len(nums)):
    sum[i+1] = sum[i] + nums[i]
ans = 0
for i in range(0, len(nums), 2):
    left = i
    right = min(i + add, len(nums))
    tmp = sum[right] - sum[left]
    ans = max(tmp, ans)

print(ans)
# -*- coding: utf-8 -*-
import math
from itertools import combinations_with_replacement


N = int(input())
items = {}
for n in list(range(N)):
  nth, a, b = map(int, input().split())
  items[n] = [nth, a, b]


def calcPosFromMoves(moves: list) -> list:
  points = {"x": 0, "y":0}
  for move in moves:
    points["x"] += move[0]
    points["y"] += move[1]
  return [points["x"], points["y"]]

def createMovePatterns(count: int) -> list:
  moves = [(1,0), (-1,0), (0,1), (0,-1)]
  return list(combinations_with_replacement(moves, count))
 
def observeTwoPoints(_observed: list, _expectation: list) -> bool:
  # print(observed,'?',expectation, '\n')
  result = [o == e for o, e in zip(_observed, _expectation)]
  return all(result)
    
def readByOneLine(_items: dict) -> list:
  _judges = []
  append = _judges.append
  for l, item in _items.items():  # read one line at once
    patterns = createMovePatterns(item[0])
    expectation = [item[1], item[2]]
    for pattern in patterns:  # brute force
      observed = calcPosFromMoves(pattern) 
      if observeTwoPoints(observed, expectation): 
        append(True)
        break;
  return _judges

judges = readByOneLine(items)
print('{}'.format('Yes' if len(judges) == N and all(judges) else 'No'))


### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
print("{}".format('Even' if ((a*b)%2 == 0) else 'Odd'))
N M = map(int,input().split())
List = [map(int,input().split())]
print(N-sum(List) if N-sum(List) >= 0 else -1)

### FIXED CODE ###

N,M= map(int,input().split())
List = list(map(int,input().split()))
print(N-sum(List) if N-sum(List) >= 0 else -1)
def d_maze_master(INF=float('inf')):
    from collections import deque
    H, W = [int(i) for i in input().split()]
    Maze = [list(input()) for _ in range(H)]

    start_row, start_col = None, None
    for row in range(H):
        for col in range(W):
            if Maze[row][col] == '.':
                start_row, start_col = row, col
                break
        else:
            continue
        break

    diff = ((-1, 0), (0, 1), (1, 0), (0, -1))

    def is_inside(row, col):
        return 0 <= row < H and 0 <= col < W

    queue = deque([(start_row, start_col)])
    dist = [[INF for _ in range(W)] for _ in range(H)]
    dist[start_row][start_col] = 0
    while queue:
        row, col = queue.pop()
        for dr, dc in diff:
            nr, nc = row + dr, col + dc
            if is_inside(nr, nc) and Maze[nr][nc] != '#' and dist[nr][nc] == INF:
                queue.appendleft((nr, nc))
                dist[nr][nc] = dist[row][col] + 1

    start_row, start_col = None, None
    maximum = 0
    for row in range(H):
        for col in range(W):
            if Maze[row][col] != '#' and dist[row][col] > maximum:
                maximum = dist[row][col]
                start_row, start_col = row, col

    queue = deque([(start_row, start_col)])
    dist = [[INF for _ in range(W)] for _ in range(H)]
    dist[start_row][start_col] = 0
    while queue:
        row, col = queue.pop()
        for dr, dc in diff:
            nr, nc = row + dr, col + dc
            if is_inside(nr, nc) and Maze[nr][nc] != '#' and dist[nr][nc] == INF:
                queue.appendleft((nr, nc))
                dist[nr][nc] = dist[row][col] + 1

    ans = 0
    for row in range(H):
        for col in range(W):
            if Maze[row][col] != '#' and dist[row][col] > ans:
                ans = dist[row][col]
    return ans

print(c_welcome_to_atcoder())

### FIXED CODE ###

def d_maze_master(INF=float('inf')):
    from collections import deque
    H, W = [int(i) for i in input().split()]
    Maze = [list(input()) for _ in range(H)]

    def bfs(start_row, start_col):
        diff = ((-1, 0), (0, 1), (1, 0), (0, -1))

        def is_inside(row, col):
            return 0 <= row < H and 0 <= col < W

        queue = deque([(start_row, start_col)])
        dist = [[INF for _ in range(W)] for _ in range(H)]
        dist[start_row][start_col] = 0
        while queue:
            row, col = queue.pop()
            for dr, dc in diff:
                nr, nc = row + dr, col + dc
                if is_inside(nr, nc) and Maze[nr][nc] != '#' and dist[nr][nc] == INF:
                    queue.appendleft((nr, nc))
                    dist[nr][nc] = dist[row][col] + 1
        return dist

    ans = 0
    for start_row in range(H):
        for start_col in range(W):
            if Maze[start_row][start_col] == '#':
                continue
            dist = bfs(start_row, start_col)
            for row in range(H):
                for col in range(W):
                    if Maze[row][col] != '#':
                        ans = max(ans, dist[row][col])
    return ans

print(d_maze_master())
n=int(input())
c=[0]*10
for i in range(1:10):
    c[i]=(int(n**(1/i)))**i
    if c[i]>n:
        c[i]=0
print(max(c))

### FIXED CODE ###

x = int(input())
a =[1]
c = 1
n = 2
while c <= 33:
    n = 2
    c += 1
    while c**n<=1000:
        a.append(c**n)
        n += 1
for i in range(len(a)):
    if a[i] > x:
        a[i] = -1000
    else:
        a[i] -= x
print(a[a.index(max(a))]+x)
s = input()
print("x"*len(s)-1)

### FIXED CODE ###

s = input()
print("x"*len(s))