Harryxun/stf_run huggingface dataset:
n = input()
s = [input() for i in range(n)]
u = set(s)
dic = dict(zip(u, [0]*len(u)))
for i in range(n):
    dic[s[i]] += 1
m = max(dic.values())
res = []
for k, v in dic.items():
    if v == m:
        res.appned(k)
res.sort()
print(*res, sep="\n")

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

S = sorted(S)
ls = [[] for i in range(N + 1)]
max_num = 0
left = 0
right = 0
while right < N:
    while right < N and S[left] == S[right]:
        right += 1
    if (right  - left) >= max_num:
        ls[right - left].append(S[left].decode())
        max_num = right - left
    left = right
    
print('\n'.join(ls[max_num]))
a,b = map(int,input().split())
print((a*b)-a-b+1))

### FIXED CODE ###

a,b = map(int,input().split())
print((a*b)-a-b+1)
list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]
list3 = [2]
x, y = map( int, input().split() )
if ( x in list1 and y in list1 ) \
　　or ( x in list2 and y in list2 ) \ 
　　or ( x in list3 and y in list3 ) : 
   print( "Yes" )
else :
   print( "No" )

### FIXED CODE ###

l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
l3 = [2]
x, y = map( int, input().split() )
if ( x in l1 and y in l1 ) or ( x in l2 and y in l2 ) or ( x in l3 and y in l3 ) : 
   print( "Yes" )
else :
   print( "No" )
a,b = map(int,input().split())
if a%2 == 1 and b%2 ==1:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

a,b = map(int,input().split())
if a%2 == 1 and b%2 ==1:
  print("Yes")
else:
  print("No")
n = int(input())
lista = [4:101:4]
listb = [7:101:7]
flag = False
for i in lista:
    for j in listb:
        if i+j == n:
            flag = True
            break
if flag:
    print('Yes')
else:
    print('No')    


### FIXED CODE ###

n = int(input())
lista = [4*i for i in range((100//4)+1)]
listb = [7*i for i in range((100//7)+1)]
flag = False
for i in lista:
    for j in listb:
        if i+j == n:
            flag = True
if flag:
    print('Yes')
else:
    print('No')
N,K = map(int, input().split())
if N > K and N//K>2:
	a = N//K
	N= N-K*(a-2)

while N>0:
	T = N
	N = abs(N-K)
	if N >T:
		break

print(min(N,T))

### FIXED CODE ###

N,K = map(int, input().split())
if N > K and N//K>2:
	a = N//K
	N= N-K*(a-2)

while N>0:
	T = N
	N = abs(N-K)
	if N >T:
		break

print(N if N==0 else min(N,T) )
import numpy as np
MOD = 10**9 + 7

def fft_convolve(f, g):
  Lf, Lg = f.shape[-1], g.shape[-1]
  L = Lf + Lg - 1
  fft_len = 1 << L.bit_length()
  fh, fl = f >> 15, f & (1 << 15) - 1
  gh, gl = g >> 15, g & (1 << 15) - 1
  def conv(f, g):
    Ff = np.fft.rfft(f, fft_len)
    Fg = np.fft.rfft(g, fft_len)
    h = np.fft.irfft(Ff * Fg)
    return np.rint(h)[..., :L].astype(np.int64) % MOD
  x = conv(fl, gl)
  z = conv(fh, gh)
  y = conv(fl + fh, gl + gh) - x - z
  return (x + (y << 15) + (z << 30)) % MOD

s = input()
x, y = map(int, input().split())

Rob = list(s.split("T"))

X = [len(r) for r in Rob[::2]]
Y = [len(r) for r in Rob[1::2]]

if abs(x-X[0]) <= sum(X[1:]) and y <= sum(Y):
  L = [0]*(2*X[0]+1)
  L[-1] = 1
  f = np.array(L, np.int64)
  for i in X[1:]:
    L = [0]*(2*i+1)
    L[0], L[-1] = 1, 1
    f = np.convolve(f, np.array(L, np.int64))
  FlagX = f[abs(x)+sum(X)]

  g = np.array([1], np.int64)
  for j in Y:
    L = [0]*(2*j+1)
    L[0], L[-1] = 1, 1
    g = np.convolve(g, np.array(L, np.int64))
  FlagY = g[abs(y)+sum(Y)]

  if FlagX and FlagY:
    print("Yes")
  else:
    print("No")
else:
  print("No")

### FIXED CODE ###

import numpy as np
MOD = 10**9 + 7

def fft_convolve(f, g):
  Lf, Lg = f.shape[-1], g.shape[-1]
  L = Lf + Lg - 1
  fft_len = 1 << L.bit_length()
  fh, fl = f >> 15, f & (1 << 15) - 1
  gh, gl = g >> 15, g & (1 << 15) - 1
  def conv(f, g):
    Ff = np.fft.rfft(f, fft_len)
    Fg = np.fft.rfft(g, fft_len)
    h = np.fft.irfft(Ff * Fg)
    return np.rint(h)[..., :L].astype(np.int64) % MOD
  x = conv(fl, gl)
  z = conv(fh, gh)
  y = conv(fl + fh, gl + gh) - x - z
  return (x + (y << 15) + (z << 30)) % MOD

s = input()
x, y = map(int, input().split())

Rob = list(s.split("T"))

X = [len(r) for r in Rob[::2]]
Y = [len(r) for r in Rob[1::2]]

if x < 0:
  y = abs(y)
  Xst = X[0]
  X = sorted(X[1:])
  if abs(x-Xst) <= sum(X) and y <= sum(Y):
    f = np.array([1], np.int64)
    for i in X:
      L = [0]*(2*i+1)
      L[0], L[-1] = 1, 1
      f = np.convolve(f, np.array(L, np.int64))
    FlagX = f[abs(x-Xst)+sum(X)]
    g = np.array([1], np.int64)
    for j in Y:
      L = [0]*(2*j+1)
      L[0], L[-1] = 1, 1
      g = np.convolve(g, np.array(L, np.int64))
    FlagY = g[y+sum(Y)]
    if FlagX and FlagY:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  x, y = abs(x), abs(y)
  if x <= sum(X) and y <= sum(Y):
    f = np.array([1], np.int64)
    for i in X:
      L = [0]*(2*i+1)
      L[0], L[-1] = 1, 1
      f = np.convolve(f, np.array(L, np.int64))
    FlagX = f[x+sum(X)]
    g = np.array([1], np.int64)
    for j in Y:
      L = [0]*(2*j+1)
      L[0], L[-1] = 1, 1
      g = np.convolve(g, np.array(L, np.int64))
    FlagY = g[y+sum(Y)]
    if FlagX and FlagY:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
from decimal import Decimal
A,B = map(str,input().split())
A = Decimal(A)
B = Decimal(B)
print(int(A*B))

### FIXED CODE ###

# ABC169 D Div Game

n = int(input())

def factorization(n):
    arr = []
    if n == 1:
        return arr
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f_list = factorization(n)
cnt = 0
for i in range(len(f_list)):
    _tmp = f_list[i][1]
    j = 1
    while _tmp >= 0:
        _tmp -= j
        j += 1
        cnt += 1
    cnt -= 1

print(cnt)
[a, b] = map(int, input().split())
print(a*b + " " + (a+b)*2)

### FIXED CODE ###

[a, b] = map(int, input().split())
print(a*b, (a+b)*2)
import math
import sys
import collections
import bisect
import sympy
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    s = readline()
    cnt = 0
    for i in range(1000):
        x = str(i).zfill(3)
        a = s[:-1].find(x[0])
        if a != -1:
            b = s[a + 1: -1].find(x[1])
            if b != -1:
                c = s[a + b + 2:].find(x[2])
                if c != -1:
                    cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    s = readline().rstrip()
    cnt = 0
    for i in range(1000):
        x = str(i).zfill(3)
        a = s[:-1].find(x[0])
        if a != -1:
            b = s[a + 1: -1].find(x[1])
            if b != -1:
                c = s[a + b + 2:].find(x[2])
                if c != -1:
                    cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()
INF=10**9+7
D = [INF]*(10**6+1)
L = [True]*(10**6+1)
L[0] = False
L[1] = False
D[1] = 1
for i in range(2, 10**6+1):
    if L[i]:
        D[i] = i
        for j in range(i*2, 10**6+1, i):
            L[j] = False
            D[j] = min(i, D[j])


def egcd(a, b):
    if a == 0:
        return b
    else:
        g = egcd(b % a, a)
        return g


def factorization(n):
    if n == 1:
        return {1}
    ans = set()
    ans.add(D[n])
    factorization(n//D[n])
    return ans


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

s = set(factorization(A[0])-{1})
for i in range(1, N):
    tmp = factorization(A[i])-{1}
    if tmp & s != set():
        break
    s |= tmp
else:
    print('pairwise coprime')
    exit()

L1 = A
while len(L1) > 1:
    l = len(L1)//2
    k = [0]*l
    for i in range(l):
        k[i] = egcd(L1[2*i], L1[2*i+1])
    if len(L1) % 2 == 1:
        k.append(L1[-1])
    L1 = k

if L1[0] == 1:
    print('setwise coprime')
else:
    print('not coprime')

### FIXED CODE ###

d,t,s=list(map(int, input().split()))
if s*t>=d:
  print('Yes')
else:
  print('No')
S = input()
T = input()
if (T = S+1):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
T = input()
if (T[:-1] == S):
  print("Yes")
else:
  print("No")
N, K = map(int, input().split())
a_array = [int(i) for i in input().split()]

countR=0
countA=0

for i in range(N):
    for j in range(i+1, N):
        if a_array[i] > a_array[j]:
            countR += 1

    for j in range(N):
        if a_array[i] > a_array[j]:
            countA += 1

print((countR * K + int(countA * K * (K-1) / 2)))%(10**9+7)

### FIXED CODE ###

N, K = map(int, input().split())
a_array = [int(i) for i in input().split()]

countR=0
countA=0

for i in range(N):
    for j in range(i+1, N):
        if a_array[i] > a_array[j]:
            countR += 1

    for j in range(N):
        if a_array[i] > a_array[j]:
            countA += 1

print(int((countR * K + countA * K * (K-1) // 2)%(10**9+7)))
N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

T.sort()
if not L.count(T[len(T)-1])<N//3
  T.reverse()

for i in range(N):
  for j in range(len(T)):
    if T[j]!=L[i]:
      print(T[j])
      break
    elif len(T)==1:
      print(T[j])

### FIXED CODE ###

N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)
S, T = map(str, input().split())
list_S = list(S)
list_T = list(T)
count = 0
for i in range(3):
    if list_S[i] == list_T[i]:
        count += 1
print(count)

### FIXED CODE ###

S = list(input())
T = list(input())

count = 0
for i in range(3):
    if S[i] == T[i]:
        count += 1
print(count)
a = int(input())
ans = a*(1+a+a*a*)
print(ans)

### FIXED CODE ###

a = int(input())
ans = a + (a*a) + (a*a*a)
print(ans)
N = int(input())
sta = list(map(int, input().split()))
sta2 = []

count_i = 0
for i in sta:
    sta2.append(i)
    if i <= min(sta2):
        count_i += 1

print(count_i)

### FIXED CODE ###

import sys
import os

#fname = "..\problems\problem1.txt"
#f = open(fname, 'r')
#sys.stdin = f

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

if N == M:
    print('Yes')
else:
    print('No')
N = int(input())
A = list(map(int, input().split()))
A_ = {}

for a in A:
  if a not in A_:
    A_[a] = 1
  else:    
    A[a] += 1
    break
if len(A) == len(A_):
  print("YES")
else:
  print("NO")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A_ = {}

for a in A:
  if a not in A_:
    A_[a] = 1
  else:    
    A_[a] += 1
    break
if len(A) == len(A_):
  print("YES")
else:
  print("NO")
import numpy as np
 
def prime(n):
    primes = np.zeros(n + 1, dtype=np.bool)
    primes[2] = 1
    primes[3::2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            primes[p * p::2 * p] = 0
    return primes
pp=prime(10**3)
p=[]
for i in range(2,1001):
  if pp[i]:
    p.append(i)
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

g=a[0]
for i in a[1:]:
  g=gcd(g,i)
if g==1:
  mm=[0 for i in range(10**6+1)]
  f=True
  for i in a:
    if mm[i]:
      ptint(i)
      f=False
      break
    mm[i]=1
    for j in range(168):
      if i%p[j]==0:
        if mm[p[j]] and i!=p[j]:
          f=False
          break
        mm[p[j]]=1
        if mm[i//p[j]] and i//p[j]!=p[j] and i!=p[j]:
          f=False
          break
        mm[i//p[j]]=1
    if not f:
      break
  if f:
    print("pairwise coprime")
  else:
    print("setwise coprime")
else:
  print("not coprime")
      


### FIXED CODE ###

def prime(n):
    primes = [0, 1] * (n // 2 + 1)
    if n % 2 == 0:
        primes.pop()
    primes[1] = 0
    primes[2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            for q in range(p * p, n + 1, 2 * p):
                primes[q] = 0
    return primes
pp=prime(10**3)
p=[]
for i in range(2,1001):
  if pp[i]:
    p.append(i)
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

g=a[0]
for i in a[1:]:
  g=gcd(g,i)
if g==1:
  mm=[0 for i in range(10**6+1)]
  f=True
  for i in a:
    if mm[i] and i!=1:
      f=False
      break
    mm[i]=1
    si=i**0.5
    for j in range(168):
      if p[j]>si:
        break
      if i%p[j]==0 and i!=p[j]:
        if mm[p[j]]:
          f=False
          break
        mm[p[j]]=1
        t=i//p[j]
        if mm[t] and t!=p[j]:
          f=False
          break
        mm[t]=1
    if not f:
      break
  if f:
    print("pairwise coprime")
  else:
    print("setwise coprime")
else:
  print("not coprime")
n=input()
l=[1,9]
for i in n:
    print(l[l.index(i)-1],end='')
print()
    n=input()
l=['1','9']
for i in n:
    print(l[l.index(i)-1], end = '')
print()
    

### FIXED CODE ###

#!/usr/bin/env python3
n=input()
l=['1','9']
for i in n:
    print(l[l.index(i)-1], end = '')
print()
import numpy as np

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = np.array(list(map(int, input().split(' '))))

# print(N - sum([np.any(P[:i+1] < P[i]) for i in range(N)]))
ar_bool = (P >= P.reshape(-1,1))
counta = 0
for i in range(N):
    counta += np.any((ar_bool)[i][:i+1])
print(counta)


### FIXED CODE ###

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = list(map(int, input().split(' ')))

p_min = P[0]
ans = 0
for p in P:
    if p <= p_min:
        p_min = p
        ans += 1
print(ans)
import copy
import sys
sys.setrecursionlimit(10**9)

def dfs(G, v, p, d):
    depth[v] = d
    for nv in G[v]:
        if nv == p:
            continue
        dfs(G, nv, v, d+1)


n, T, A = map(int,input().split())
T -= 1
A -= 1
g = [[] for _ in range(n)]
for i in range(n-1):
    x, y = map(int,input().split())
    x -= 1
    y -= 1
    g[x].append(y)
    g[y].append(x)

depth = [0]*n
GT = copy.deepcopy(g)
GT[T].append(-1)
root = T
dfs(GT, root, -1, 0)
dt = depth.copy()

depth = [0]*n
GA = copy.deepcopy(g)
GA[A].append(-1)
root = A
dfs(GA, root, -1, 0)
da = depth.copy()

def dfs2(G, v, p):
    for nv in G[v]:
        if nv == p:
            continue
        if dt[nv] <= da[nv]:
            maxd[0] = max(maxd[0], da[nv])
        else:
            continue
        dfs2(G, nv, v)


maxd = [-float('inf')]
root = T
dfs2(GT, root, -1)
if maxd[0] == -float('inf'):
    print(0)
else:
    print(maxd[0]-1)

### FIXED CODE ###

import copy
import sys
sys.setrecursionlimit(10**9)

def dfs(G, v, p, d, depth):
    depth[v] = d
    for nv in G[v]:
        if nv == p:
            continue
        dfs(G, nv, v, d+1, depth)
    return G, depth


n, T, A = map(int,input().split())
T, A = T-1, A-1
g = [[] for _ in range(n)]
for i in range(n-1):
    x, y = map(int,input().split())
    x, y = x-1, y-1
    g[x].append(y)
    g[y].append(x)

depth = [0]*n
GT = copy.deepcopy(g)
GT[T].append(-1)
GT, dt = dfs(GT, T, -1, 0, depth)

depth = [0]*n
GA = copy.deepcopy(g)
GA[A].append(-1)
GA, da = dfs(GA, A, -1, 0, depth)

ans = 0
for t, a in zip(dt, da):
    if t <= a:
        ans = max(ans, a)
print(ans-1)
A = input('Aを入力してください')
B = input('Bを入力してください')
K = input('Cを入力してください')
#print('A= ', A)
#print('B= ', B)
#print('K= ', K)

#A = 1
#B = 10
#K = 6

ANS = []

for i in range(K + 1):
    ANS.append(A + i)


for j in range(K + 1):
    if B - j not in ANS:
        ANS.append(B - j)

ANS.sort()

print(ANS)

#for i in range(len(ANS)):
#    print(ANS[i])


### FIXED CODE ###

import sys

#A = input('Aを入力してください')
#B = input('Bを入力してください')
#K = input('Cを入力してください')
#print('A= ', A)
#print('B= ', B)
#print('K= ', K)

#A = 1
#B = 10
#K = 6

#S = input('ABKを入力してください')
S = input()
S = S.split(' ')

#for i in range(len(S)):
#    print(S[i])

#sys.exit()

A = int(S[0])
B = int(S[1])
K = int(S[2])

ANS = []
for i in range(K):
    if A + i <= B:
        ANS.append(A + i)


for j in range(K):
    if B - j not in ANS and B - j >= A:
        ANS.append(B - j)

ANS.sort()

#print(ANS)

for i in range(len(ANS)):
    print(ANS[i])
N,Y=map(int,input().split())
Y=Y//1000
error='-1 -1 -1'

for x in range(N+1):
    for y in range(N+1-x):
            z=N-x-y
            if 10*x+5*y+z==Y and z>=0:
                ans=str(x[0])+' '+str(y[0])+' '+str(z[0])
                exit()
print(error)

### FIXED CODE ###

N,Y=map(int,input().split())
Y=Y//1000
error='-1 -1 -1'

for x in range(N+1):
    for y in range(N+1-x):
            z=N-x-y
            if 10*x+5*y+z==Y and z>=0:
                print(str(x)+' '+str(y)+' '+str(z))
                exit()
print(error)
n  = int(input())
print(a+a*a+a*a*a)

### FIXED CODE ###

a = int(input())
print(a+a*a+a*a*a)
H, W = map(int,input().split())
map = [input() for i in range(H)]

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == "#":
    return "Yes"
  if j < W-1 and map[i][j+1] == "#":
    return "Yes"
  if i > 0 and map[i-1][j] == "#":
    return "Yes"
  if i < H -1 and map[i+1][j] == "#":
    return "Yes"
  return "No"


for i in range(H):
  for j in range(W):
    if map[i][j] == "#":
      ans = drow(i,j)
      if ans == "No":
        break
if H == 1 and W == 1:
  ans = "No"
  if map[0][0] == "#":
    ans = "Yes"
print(ans)
    

### FIXED CODE ###

H, W = map(int,input().split())
map = [input() for i in range(H)]

def drow(i,j, map = map):
  if j > 0 and map[i][j-1] == "#":
    return "Yes"
  if j < W-1 and map[i][j+1] == "#":
    return "Yes"
  if i > 0 and map[i-1][j] == "#":
    return "Yes"
  if i < H -1 and map[i+1][j] == "#":
    return "Yes"
  return "No"

ans = "Yes"
for i in range(H):
  for j in range(W):
    if map[i][j] == "#":
      ans = drow(i,j)
      if ans == "No":
        print(ans)
        exit()
print(ans)
N = int(input())
h = list(map(int, input().split()))

dp = [0] * (N+2)

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))

print(dp[N-1])


### FIXED CODE ###

inf = 10**9 + 7
n = int(input())
nodes = list(map(int, input().split()))
dp = [inf] * n

dp[0] = 0


for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1]+abs(nodes[i]-nodes[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2]+abs(nodes[i]-nodes[i-2]))

print(dp[n-1])
import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)

result={}
pre_idx=""
tmp=[]
for i in range(NM[1]):
    s=input().split(" ")
    idx=s[0]
    if(pre_idx==idx):
        tmp.append(s[1])
        if(i==NM[1]-1):
            result[pre_idx]=tmp
    elif(pre_idx!=idx):
        tmp=[]
        result[idx]=tmp
        tmp.append(s[1])
        pre_idx=idx

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    idx=L.index('AC')
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))

### FIXED CODE ###

import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)

result={}
tmp=[]

for i in range(NM[1]):
    s=input().split(" ")
    result.setdefault(s[0],[]).append(s[1])

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    if('AC' in L):
        idx=L.index('AC')
    else:
        idx=-1
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))
x, y = map(int, input.split())
if y % 2 == 1:
  print('No')
elif x * 4 < y:
  print('No')
elif x * 2 > y:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

x, y = map(int, input().split())
if y % 2 == 1:
  print('No')
elif x * 4 < y:
  print('No')
elif x * 2 > y:
  print('No')
else:
  print('Yes')
s = input()

if len(s) == 1:


tmp = []
for i in range(len(s)-1):
        if s[i] != s[i+1]:
                tmp.append(max(i+1,len(s)-(i+1)))

if len(tmp) == 0:
        #元から全部同じ
        print(len(s))
else:
        print(min(tmp))

### FIXED CODE ###

s = input()



tmp = []
for i in range(len(s)-1):
        if s[i] != s[i+1]:
                tmp.append(max(i+1,len(s)-(i+1)))

if len(tmp) == 0:
        #元から全部同じ
        print(len(s))
else:
        print(min(tmp))
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
xs = list(map(int, input().split()))

G = [set() for _ in range(N+1)]
es = []
for i in range(M):
    u, v = map(int, input().split())
    if xs[u-1] == xs[v-1]:
        G[v].add(u)
        G[u].add(v)
    elif xs[u-1] > xs[v-1]:
        G[u].add(v)
    else:
        G[v].add(u)
    e = (min(u,v), max(u,v))
    es.append(e)

xs = sorted([(x,i+1) for i, x in enumerate(xs)])
d = dict()
cc = dict()
for i in range(N):
    if not (G[i+1] or G2[i+1]):
        print(-1)
        sys.exit()
for x, u in xs:
    if u in cc:
        continue
    cc[u] = 1
    for c in G[u]:
        if c in cc:
            cc[u] = 1-cc[c]
    stack = [u]
    while stack:
        q = stack.pop()
        for c in G[q]:
            e = (min(q,c), max(q,c))
            d[e] = x
            if c in cc:
                continue
            stack.append(c)
            cc[c] = 1 - cc[q]
print("".join("BW"[cc[i]] for i in range(1,N+1)))
for i in range(M):
    print(d[es[i]])



### FIXED CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
bxs = list(map(int, input().split()))
xs = bxs[:]
dd = defaultdict(set)
for i, x in enumerate(xs):
    dd[x].add(i+1)
xs = list(set(xs))
xs.sort()

#for x, i in xs:
G = [set() for _ in range(N+1)]
G2 = [set() for _ in range(N+1)]
es = []
for i in range(M):
    u, v = map(int, input().split())
    if bxs[u-1] == bxs[v-1]:
        G[v].add(u)
        G[u].add(v)
    elif bxs[u-1] > bxs[v-1]:
        G[u].add(v)
    else:
        G[v].add(u)
    e = (min(u,v), max(u,v))
    es.append(e)

r = True
d = dict()
cc = [-1 for _ in range(N+1)]
for i in range(N):
    if len(G[i+1]) == 0:
        print(-1)
        sys.exit()
for x in xs:
    for u in dd[x]:
        if cc[u] != -1:
            continue
        for c in G[u]:
            if cc[c] == -1:
                cc[u] = 1
                break
            else:
                cc[u] = 1-cc[c]
        stack = [u]
        while stack:
            q = stack.pop()
            for c in G[q]:
                e = (min(q,c), max(q,c))
                if e in d:
                    continue
                d[e] = x
                if cc[c] != -1:
                    continue
                stack.append(c)
                cc[c] = 1 - cc[q]
for i in range(1, N+1):
    if cc[i] == -1:
        print(-1)
        sys.exit()
for i in range(1, N+1):
    print("B"if cc[i] else "W", end="")
print()
for i in range(M):
    print(d[es[i]])
S = input()
Q = int(input())
parity = 0

for i in range(Q):
    query = input().split()
    if query == '1':
        parity += 1
    else:
        if int(query[1]) == 1 + (parity % 2):
            S = query[2] + S
        else:
            S = S + query[2]

if parity % 2 == 1:
    S = S[::-1]
print(S)

### FIXED CODE ###

from collections import deque
S = deque(list(input()))
Q = int(input())
parity = 0

for i in range(Q):
    query = input().split()
    if len(query) == 1:
        parity += 1
    else:
        if int(query[1]) == 1 + (parity % 2):
            S.appendleft(query[2])
        else:
            S.append(query[2])
S = ''.join([c for c in S])
if parity % 2 == 1:
    S = S[::-1]
print(S)
lis = [int(input()) for _ in range(6)]
print(lis(0)//min(lis[1:])+5)


### FIXED CODE ###

lis = [int(input()) for _ in range(6)]
if lis[0] % min(lis[1:]) == 0:
  print(lis[0]//min(lis[1:])+4)
else:
  print(lis[0]//min(lis[1:])+5)