Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import bisect

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

m = (n-1) // 2
 
x_sorted = sorted(x)

for i in range(n):
    ind = bisect.bisect_left(x_sorted, x[i])
    print((x_sorted[0:ind] + x_sorted[ind+1:])[m])

### FIXED CODE ###

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

sorted_x = sorted(x)
l = sorted_x[n//2]
s = sorted_x[n//2-1]

for i in x:
    if i <= s:
        print(l)
    else:
        print(s)
### BUGGY CODE ###

h, w = map(int, input().split())
n = h * w
INF = 1 << 30

field = []
for i in range(h):
    field.append(input())

dist = [[INF] * n for _ in range(n)]

for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            continue
        if j + 1 < w and field[i][j+1] != '#':
            dist[i * w + j][i * w + j + 1] = 1
            dist[i * w + j + 1][i * w + j] = 1
        if i + 1 < h and field[i+1][j] != '#':
            dist[i * w + j][(i+1) * w + j] = 1
            dist[(i+1) * w + j][i * w + j] = 1

# Warshall-Floyd 
for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if dist[i][j] == INF:
            continue
        ans = max(ans, dist[i][j])

print(ans)



### FIXED CODE ###

h, w = map(int, input().split())
n = h * w
INF = 1 << 30

field = []
for i in range(h):
    field.append(input())

dist = [[INF] * n for _ in range(n)]

for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            continue
        if j + 1 < w and field[i][j+1] != '#':
            dist[i * w + j][i * w + j + 1] = 1
            dist[i * w + j + 1][i * w + j] = 1
        if i + 1 < h and field[i+1][j] != '#':
            dist[i * w + j][(i+1) * w + j] = 1
            dist[(i+1) * w + j][i * w + j] = 1

# Warshall-Floyd 
for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k])

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if dist[i][j] == INF:
            continue
        ans = max(ans, dist[i][j])

print(ans)
### BUGGY CODE ###

n,m,q=map(int,input().split())
S=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r=map(int,input().split())
    S[l][r]+=1

for i in range(q):
    a,b=map(int,input().split())
    ans=0
    for y in range(a,b+1):
        for x in range(a,b+1):
            ans+=S[x][y]
    print(ans)


### FIXED CODE ###

n,m,q=map(int,input().split())
S=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r=map(int,input().split())
    S[l][r]+=1

for i in range(1,n+1):
    for j in range(1,n):
        S[i][j+1]+=S[i][j]

for i in range(q):
    a,b=map(int,input().split())
    ans=0
    for y in range(a,b+1):
        ans+=S[y][b]-S[y][a-1]
    print(ans)
### BUGGY CODE ###

def solve():
    N, K = map(int, input().split())
    ps = list(map(int, input().split()))
    expected = max([sum(ps[left: left + K]) for left in range(N - K + 1)])
    print((expected + K) / 2)
solve()

### FIXED CODE ###

def solve():
    N, K = map(int, input().split())
    ps = list(map(int, input().split()))
    curSum = sum(ps[:K])
    curMax = curSum
    i = K; j = 0
    while i < N:
        curSum -= ps[j]
        curSum += ps[i]
        curMax = max(curSum, curMax)
        i += 1; j += 1
    print((curMax + K) / 2)
solve()
### BUGGY CODE ###

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    from bisect import bisect_left
    input = sys.stdin.buffer.readline

    N = int(input())
    A = list(map(int, input().split()))
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    que = deque()
    que.append(1)
    seen = [-1] * (N+1)
    seen[1] = 0
    dp = [[] for _ in range(N+1)]
    dp[1] = [A[0]]
    ans = [0] * (N+1)
    ans[1] = 1
    while que:
        v = que.popleft()
        flg = 1
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                que.append(u)
                if flg:
                    uu = u
                    flg = 0
                    continue
                a = A[u-1]
                j = bisect_left(dp[v], a)
                if j == len(dp[v]):
                    dp[u] = dp[v][:]
                    dp[u].append(a)
                    ans[u] = len(dp[u])
                else:
                    dp[u] = dp[v][:]
                    dp[u][j] = a
                    ans[u] = len(dp[u])
        if flg == 0:
            a = A[uu-1]
            dp[uu] = dp[v]
            j = bisect_left(dp[uu], a)
            if j == len(dp[uu]):
                dp[uu].append(a)
            else:
                dp[uu][j] = a
            ans[uu] = len(dp[uu])

    for i in range(1, N+1):
        print(ans[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    from bisect import bisect_left
    input = sys.stdin.buffer.readline

    N = int(input())
    A = list(map(int, input().split()))
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    que = deque()
    que.append(1)
    seen = [0] * (N+1)
    seen[1] = 1
    ans = [0] * (N+1)
    ans[1] = 1
    LIS = []
    change = [[] for _ in range(N+1)]
    while que:
        v = que.pop()
        if v > 0:
            que.append(-v)
            a = A[v-1]
            if not LIS:
                LIS.append(a)
                change[v] = (0, -1)
            else:
                j = bisect_left(LIS, a)
                if j == len(LIS):
                    LIS.append(a)
                    ans[v] = len(LIS)
                    change[v] = (len(LIS) - 1, -1)
                else:
                    change[v] = (j, LIS[j])
                    LIS[j] = a
                    ans[v] = len(LIS)
            for u in adj[v]:
                if seen[u] == 0:
                    seen[u] = 1
                    que.append(u)
        else:
            v = -v
            i, x = change[v]
            if x == -1:
                LIS.pop()
            else:
                LIS[i] = x
    for i in range(1, N+1):
        print(ans[i])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

S = input()
Q = int(input())

for q in range(1, Q+1):
    query = input()
    if query[0] == "1":
        S = "".join(reversed(S))
    else:
        T, F, C = query.split()
        if F == "1":
            S = C + S
        else:
            S += C

print(S)

### FIXED CODE ###

S = input()
Q = int(input())

rev = False
l, r = "", ""

for _ in range(Q):
    query = input()
    if query[0] == "1":
        rev = not rev
    else:
        T, F, C = query.split()
        if F == "1":
            if rev:
                r += C
            else:
                l = C + l
        else:
            if rev:
                l = C + l
            else:
                r += C

res = l + S + r
if rev:
    res = res[::-1]

print(res)
### BUGGY CODE ###

import itertools

N = int(input())
S = []
for i in range(N):
    s = list(input())
    s.sort()
    S.append(s)

NL = [i for i in range(N)]
X = itertools.combinations(NL, 2)

ans = 0
for i in X:
    if S[i[0]] == S[i[1]]:
        ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
A = {}
for i in range(N):
    S = list(input())
    S.sort()
    S = ''.join(S)
    A[S] = A.get(S, 0) + 1

ans = 0
for i in A.values():
    if i > 1:
        iL = [j for j in range(i)]
        ans += sum(iL)
    
print(ans)
### BUGGY CODE ###

def main():
    from sys import stdin
    input=stdin.readline
    
    h, w, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    ab_d = {a*(10**9)+b-1 for a, b in ab}

    ans = [set() for _ in range(9)]
    for a, b in ab:
        temp = [None for _ in [0]*25]
        for i in range(5):
            for j in range(5):
                if 0 < a+i-2 <= h and 0 < b+j-2 <= w:
                    if (a+i-2)*(10**9)+b+j-3 in ab_d:
                        temp[i*5+j] = 1
                    else:
                        temp[i*5+j] = 0
        for i in range(3):
            for j in range(3):
                cnt = [temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
                if None not in cnt:
                    ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)

    for i in range(9):
        ans[i] = len(ans[i])

    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)


main()


### FIXED CODE ###

h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for i in range(5):
        for j in range(5):
            if 0<a+i-2<=h and 0<b+j-2<=w:
                if (a+i-2)*(10**9)+b+j-3 in ab_d:
                    temp[i*5+j]=1
                else:
                    temp[i*5+j]=0
    for i in range(3):
        for j in range(3):
            cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
            if None not in cnt:
                ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
for i in range(9):
    ans[i]=len(ans[i])

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)
### BUGGY CODE ###

S = input()
ls_rem = [int(S[i:])%2019 for i in range(len(S))]
ls_rem.append(0)
from collections import Counter
C_rem = Counter(ls_rem)
ans=0
for i in C_rem.keys():
  n=C_rem[i]
  ans+=n*(n-1)/2
print(int(ans))  

### FIXED CODE ###

S = input()[::-1]

#aのMOD求めるンゴ
MOD=2019
ls_rem_a=[]
d=1
for i in range(len(S)):
  ls_rem_a.append(int(S[i])*d%MOD)
  d = d*10%MOD

#次に累積和求めるンゴ
ls_rem_s=[0]
sum=0
for i in range(len(S)):
  sum+=ls_rem_a[i]
  sum%=MOD
  ls_rem_s.append(sum)

#最後にMODが同じやつの個数を調べるンゴ
from collections import Counter
C_rem = Counter(ls_rem_s)
ans=0
for i in C_rem.keys():
  n=C_rem[i]
  ans+=n*(n-1)//2
print(ans)
### BUGGY CODE ###

N = int(input())
#A = [list(map(int,input().split())) for i in range(N)]
#print (A)
def bubble_sort(arr1,arr2,n):
    for i in range(n):
        for j in range(0,n-i-1):
            if arr1[j] > arr1[j+1]:
                arr1[j],arr1[j+1] = arr1[j+1],arr1[j]
                arr2[j],arr2[j+1] = arr2[j+1],arr2[j]





A = []
B = []
for i in range(N):
    tmp1,tmp2 = map(int,input().split())
    A.append(tmp1)
    B.append(tmp2)
bubble_sort(A,B,N)
base = A[-1]
addition = B[-1]

print(base + addition)


### FIXED CODE ###

N = int(input())
#A = [list(map(int,input().split())) for i in range(N)]
#print (A)
def bubble_sort(arr1,arr2,n):
    for i in range(n):
        for j in range(0,n-i-1):
            if arr1[j] > arr1[j+1]:
                arr1[j],arr1[j+1] = arr1[j+1],arr1[j]
                arr2[j],arr2[j+1] = arr2[j+1],arr2[j]





A = []
B = []
max_key = 0
max_value = 0
for i in range(N):
    tmp1,tmp2 = map(int,input().split())
    A.append(tmp1)
    B.append(tmp2)
    if tmp1 > max_key:
        max_key = tmp1
        max_value = tmp2
print(max_value+max_key)
#bubble_sort(A,B,N)
#base = A[-1]
#addition = B[-1]


#print(base + addition)
### BUGGY CODE ###

S = input()
l = len(S)
t = True
nex = 0
while t:
    s = S
    for i in range(len(S)-1):
        if nex == 1:
            nex = 0
            continue
        if S[i:i+2] == '01' or S[i:i+2] == '10':
            s = s[:i] + '--' + s[i+2:]
            nex = 1
    #print('s',s)
    s = s.replace('-','')
    if s == S:
        print(l-len(S))
        exit()
    if len(s) == 0:
        print(l)
        exit()
    S = s

### FIXED CODE ###

S = input()
C1 = 0
C0 = 0
for i in range(len(S)):
    if S[i] == '1':
        C1 +=1
    if S[i] == '0':
        C0 +=1

print(min(C0,C1)*2)
### BUGGY CODE ###

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, T = lr()
AB = [lr() for _ in range(N)]
AB.sort()
# 最後の注文はAiが選ぶ料理で最大で、T-1分後に注文するとして良い
dp_left = [np.zeros(T, np.int32) for _ in range(N+2)]
dp_right = [np.zeros(T, np.int32) for _ in range(N+2)]

for i in range(1, N+1):
    a, b = AB[i-1]
    dp_left[i][a:] = np.maximum(dp_left[i-1][a:], dp_left[i-1][:-a] + b)

for i in range(N, 0, -1):
    c, d = AB[i-1]
    dp_right[i][c:] = np.maximum(dp_right[i+1][c:], dp_right[i+1][:-c] + d)

temp_ans = 0
for i in range(N):
    a, b = AB[i]
    for j in range(T):
        result = dp_left[i][j] + dp_right[i+2][T-1-j] + b
        if result > temp_ans:
            temp_ans = result

print(temp_ans)


### FIXED CODE ###

import sys
import numpy as np

n, t = map(int, input().split())
knapsack = np.zeros(t, dtype=np.int64)
cuisines = [tuple(map(int, line.split())) for line in sys.stdin]
cuisines.sort()
tmp_ans = 0
for a, b in cuisines:
    tmp_ans = max(tmp_ans, knapsack.max() + b)
    knapsack[a:] = np.maximum(knapsack[a:], knapsack[:-a] + b)
print(tmp_ans)
### BUGGY CODE ###

# https://abc100.contest.atcoder.jp/tasks/abc100_c


def get_primes_dic(v):
    m = {}
    i = 2

    while i <= v:
        while v % i == 0:
            if i in m:
                m[i] += 1
            else:
                m[i] = 1
            v //= i

        i += 1

    return m


N = int(input())

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

count = 0

for i in a:
    dic = get_primes_dic(i)
    if 2 in dic:
        count += dic[2]

print(count)



### FIXED CODE ###

# https://abc100.contest.atcoder.jp/tasks/abc100_c


def even_count(v):
    if v % 2 != 0:
        return 0
    else:
        r = 0
        while v % (2 ** 20) == 0:
            r += 20
            v //= (2 ** 20)

        while v % (2 ** 10) == 0:
            r += 10
            v //= (2 ** 10)

        while v % 2 == 0:
            r += 1
            v //= 2

    return r


N = int(input())

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

count = 0

for i in a:
    count += even_count(i)

print(count)
### BUGGY CODE ###

def search(l,r) :
    counter =0;
    j=0;
    while j < len(r):
        for i in range(0,len(l)):
            if r[j]==l[i]:
                counter +=1
                break
        j+=1

    return  counter


input()
list1 = list(map(lambda  x : int(x),input().split(' ')))
input()
list2 =  list(map(lambda  x : int(x),input().split(' ')))
#print(list1)
#print(list2)
ans = search(list1,list2)
print(ans)

### FIXED CODE ###

def search(l,r) :
    counter =0;
    j=0
    i=0
    while j < len(r):
        while i < len(l):
            if r[j] > l[i]:
                i+=1
            elif r[j]==l[i]:
                counter +=1
                break
            elif r[j] < l[i]:
                break
        j+=1

    return  counter


input()
list1 = list(map(lambda  x : int(x),input().split(' ')))
input()
list2 =  list(map(lambda  x : int(x),input().split(' ')))
list1.sort()
list2.sort()

#print(list1)
#print(list2)
ans = search(list1,list2)
print(ans)
### BUGGY CODE ###

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

def floor(t):
  return int(t)

Ans_0 = 0
for x in range(min(B+1, N+1)):
  Ans = floor(A * x / B) - A * floor(x / B)
  if Ans_0 < Ans:
    Ans_0 = Ans
  
print(Ans_0)

### FIXED CODE ###

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

def floor(t):
  return int(t)

Ans = floor(A * min(N, B-1) / B)
  
print(Ans)
### BUGGY CODE ###

#AtCorder Beginner Contest 085  C Otoshidama
n, y = map(int, input().split())

a = -1
b = -1
c = -1

for i in range(n + 1):
    if 10000*i == y and i == n:
        a = i
        b = 0
        c = 0
        break
    else:
        for j in range(n-i + 1):
            if 10000*i + 5000*j == y and i+j == n:
                a = i
                b = j
                c = 0
                break
            else:
                for k in range(n - i - j + 1):
                    if 10000*i + 5000*j + 1000*k == y and i + j + k == n:
                        a = i
                        b = j
                        c = k
                        break


print(str(a) + " " + str(b) + " " + str(c))

### FIXED CODE ###

#AtCorder Beginner Contest 085  C Otoshidama
n, y = map(int, input().split())

a = -1
b = -1
c = -1

for i in range(n + 1):
    if 10000*i == y and i == n:
        a = i
        b = 0
        c = 0
        break
    else:
        for j in range(n - i + 1):
            if i+j == n and 10000*i + 5000*j == y:
                a = i
                b = j
                c = 0
                break
            elif 10000*i + 5000*j + 1000*(n - i -j) == y:
                a = i
                b = j
                c = n - i - j
                break


print(str(a) + " " + str(b) + " " + str(c))
### BUGGY CODE ###

from bisect import bisect_left, bisect_right
n = int(input())
l = list(map(int, input().split()))
l.sort()
# print(l)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        idx1 = bisect_right(l, abs(l[i] - l[j]))
        idx2 = bisect_left(l, l[i] + l[j])
        ansi = idx2 - idx1
        if abs(l[i] - l[j]) < l[i]:
            ansi -= 1
        if abs(l[i] - l[j]) < l[j]:
            ansi -= 1
        ans += ansi
        # print(l[i], l[j], idx1, idx2)

ans //= 3
print(ans)


### FIXED CODE ###

from bisect import bisect_left, bisect_right
n = int(input())
l = list(map(int, input().split()))
l.sort()
# print(l)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        idx1 = bisect_right(l, abs(l[i] - l[j]))
        idx2 = bisect_left(l, l[i] + l[j])
        ansi = idx2 - idx1
        if abs(l[i] - l[j]) < l[i]:
            ansi -= 1
        if abs(l[i] - l[j]) < l[j]:
            ansi -= 1
        ans += ansi
        # print(l[i], l[j], idx1, idx2)

ans //= 3
print(ans)
### BUGGY CODE ###

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

mod = 10**9+7

mm0 = [0 for i in range(61)]
mm1 = [0 for i in range(61)]

for i in range(n):
    for j in range(61):
        if (a[i]>>j)<0:
            break
        if (a[i]>>j)&1:
            mm1[j] += 1

ans = 0
for i in range(61):
    ttl = (n-mm1[i])*mm1[i]
    ans += ((1<<i)*ttl)%mod
    ans %= mod

print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
 
mod = 10**9+7
 
 
 
ans = 0
q2 = 1
for j in range(60):
    mm1 = 0
    for i in range(n):
        if a[i]>>j&1:
            mm1 += 1
 
    ttl = ((n-mm1)*mm1)
    ans += ((q2)*((ttl)%mod))%mod
    ans %= mod
    q2 = (q2*2)%mod
 
print(ans)
### BUGGY CODE ###

import heapq
X,Y,Z,K = map(int,input().split())
As = sorted(list(map(int,input().split())),reverse=True)
Bs = sorted(list(map(int,input().split())),reverse=True)
Cs = sorted(list(map(int,input().split())),reverse=True)
q = []
heapq.heapify(q)
heapq.heappush(q,(-(As[0]+Bs[0]+Cs[0]),0,0,0))
list_ijk = [(0,0,0)]
for i in range(K):
    # valueのマイナス値の小さい順にpop(優先度付きqueue)
    v,i,j,k = heapq.heappop(q)
    if i < len(As)-1 and (i+1,j,k) not in list_ijk:
        heapq.heappush(q,(-(As[i+1]+Bs[j]+Cs[k]),i+1,j,k))
        list_ijk.append((i+1,j,k))
    if j < len(Bs)-1 and (i,j+1,k) not in list_ijk:
        heapq.heappush(q,(-(As[i]+Bs[j+1]+Cs[k]),i,j+1,k))
        list_ijk.append((i,j+1,k))
    if k < len(Cs)-1 and (i,j,k+1) not in list_ijk:
        heapq.heappush(q,(-(As[i]+Bs[j]+Cs[k+1]),i,j,k+1))
        list_ijk.append((i,j,k+1))
    print(-v)    

### FIXED CODE ###

# どうやって自明な条件で計算量を落としていくか
# 不等式に注目。pythonが耐えるのは10^6程度
X,Y,Z,K = map(int,input().split())
As = sorted(list(map(int,input().split())),reverse=True)
Bs = sorted(list(map(int,input().split())),reverse=True)
Cs = sorted(list(map(int,input().split())),reverse=True)

# ABでソート
AB = []
for A in As:
    for B in Bs:
        AB.append(A+B)
ABs = sorted(AB,reverse=True)

# その中からK番目まで
ABC = []
for i in range(min(len(ABs),K)):
    for C in Cs:
        ABC.append(ABs[i]+C)

ABCs = sorted(ABC,reverse=True)
for i in range(K):
    print(ABCs[i])
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)

for i in range(n):
    if m > a[i]:
        print(m)
    else:
        b = a[i]
        a.remove(b)
        print(max(a))
        a.insert(i,b)


### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

b = sorted(a)

for i in a:
    if i == b[-1]:
        print(b[-2])
    else:
        print(b[-1])
### BUGGY CODE ###

H, W = map(int,input().split())
s = []
rc = [[[None]*W for _ in range(H)] for _ in range(2)]
for _ in range(H):
    s.append(list(input()))
for j in range(H):
    l = s[j]
    for i in range(W):
        if l[i] == "#":
            rc[0][j][i] = 0
        elif i > 0:
            rc[0][j][i] = rc[0][j][i-1] + 1
        else:
            rc[0][j][i] = 1
    for i in range(W-1, -1, -1):
        if l[i] == "#":
            continue
        elif i < W-1:
            rc[0][j][i] = max(rc[0][j][i+1], rc[0][j][i])
for i in range(W):
    for j in range(H):
        if s[j][i] == "#":
            rc[1][j][i] = 0
        elif j > 0:
            rc[1][j][i] = rc[1][j-1][i] + 1
        else:
            rc[1][j][i] = 1
    for j in range(H-1, -1, -1):
        if s[j][i] == "#":
            continue
        elif j < H-1:
            rc[1][j][i] = max(rc[1][j+1][i], rc[1][j][i])
ans = 0
for j in range(H):
    for i in range(W):
        ans = max(rc[0][j][i] + rc[1][j][i] - 1, ans)
print(ans)

### FIXED CODE ###

H, W = map(int,input().split())
s = []
rc = [[[None]*W for _ in range(H)] for _ in range(2)]
for _ in range(H):
    s.append(list(input()))
for j in range(H):
    l = s[j]
    for i in range(W):
        if l[i] == "#":
            rc[0][j][i] = 0
        elif i > 0:
            rc[0][j][i] = rc[0][j][i-1] + 1
        else:
            rc[0][j][i] = 1
    for i in range(W-1, -1, -1):
        if l[i] == "#":
            continue
        elif i < W-1:
            rc[0][j][i] = max(rc[0][j][i+1], rc[0][j][i])
for i in range(W):
    for j in range(H):
        if s[j][i] == "#":
            rc[1][j][i] = 0
        elif j > 0:
            rc[1][j][i] = rc[1][j-1][i] + 1
        else:
            rc[1][j][i] = 1
    for j in range(H-1, -1, -1):
        if s[j][i] == "#":
            continue
        elif j < H-1:
            rc[1][j][i] = max(rc[1][j+1][i], rc[1][j][i])
ans = 0
for j in range(H):
    for i in range(W):
        ans = max(rc[0][j][i] + rc[1][j][i] - 1, ans)
print(ans)
### BUGGY CODE ###

i = 0
x=int(input())
while x != 0:
 i = i + 1
 print("Case " + str(i) + ": " + str(x))

### FIXED CODE ###

i=0
x=int(input())
while x != 0:
 i = i+1
 print("Case " + str(i) + ": " + str(x))
 x=int(input())