Harryxun/stf_run huggingface dataset:
cards = []
for suit in ('S','H','C','D'):
    for num in range(1,14):
        cards.append(suit+' '+str(num))

N = raw_input()

while 1:
    suit, number = raw_input().split()
    cards.remove(suit+' '+y)


for card in cards:
    print card

### FIXED CODE ###

cards = []
for suit in ('S','H','C','D'):
    for num in range(1,14):
        cards.append(suit+' '+str(num))

N = int(raw_input())

for n in xrange(N):
    suit, number = raw_input().split()
    cards.remove(suit+' '+number)


for card in cards:
    print card
x,n=map(int,input().split())
lis=[i+1 for i in range(100)]
flag=True
flag2=True
if n==0:
  flag=False
  print(x)


if flag:
  p=list(map(int,input().split()))
  for i in p:
    lis.remove(i)
  if x>lis[-1]:
    print(lis[-1])
    flag2=False
  if flag2:
    for i in range(len(lis)):
      if lis[i]>x:
        id=i
        break
    if id>=1:
      if abs(x-lis[id])<abs(x-lis[id-1]):
        print(lis[id])
      else:
        print(lis[id-1])
    else:
      print(lis[0])

### FIXED CODE ###

x,n=map(int,input().split())
lis=[i-1 for i in range(103)]
flag=True
if n==0:
  flag=False
  print(x)

if flag:
  p=list(map(int,input().split()))
  for i in p:
    lis.remove(i)
  #print(lis)
  for i in range(len(lis)):
    if lis[i]>x:
      index=i
      break
  if abs(x-lis[index])<abs(x-lis[index-1]):
    print(lis[index])
  else:
    print(lis[index-1])
a,b,c=map(int,input().split())
if a+b+c==22;
    print("bust")
if a+b+c > 22;
    print("bust")
if a+b+c ==21;
    print("win")
  else:
    print("win")

### FIXED CODE ###

a,b,c=map(int,input().split())
val=a+b+c
if val > 21:
    print("bust")
else:
    print("win")
w,h = list(map(int, input().split()))
ws = []
hs = []
for i in range(w): ws.append(int(input()))
for i in range(h): hs.append(int(input()))

ws.sort(reverse = True)
hs.sort(reverse = True)

remainW = w
remainH = h
aliveW = [1 for i in range(w)]
aliveH = [1 for i in range(h)]

ans = 0
while(remainW>0 or remainH>0):
    #print(ans, remainW, remainH)
    costW = ws[remainW-1] * (remainH + 1)
    costH = hs[remainH-1] * (remainW + 1)
    if(ws[remainW-1] > hs[remainH-1] or remainW==0):
        ans += costH
        remainH-=1
    else:
        ans += costW
        remainW -= 1
print(ans)

                             



### FIXED CODE ###


w,h = list(map(int, input().split()))
ws = []
hs = []
for i in range(w): ws.append(int(input()))
for i in range(h): hs.append(int(input()))

ws.sort(reverse = True)
hs.sort(reverse = True)

remainW = w
remainH = h
aliveW = [1 for i in range(w)]
aliveH = [1 for i in range(h)]

ans = 0
while(remainW>0 or remainH>0):
    #print(ans, remainW, remainH)
    costW = ws[remainW-1] * (remainH + 1)
    costH = hs[remainH-1] * (remainW + 1)
    if(remainH!=0 and (ws[remainW-1] > hs[remainH-1] or remainW==0)):
        ans += costH
        remainH = max(0,remainH-1)
    else:
        ans += costW
        remainW = max(0,remainW-1)
print(ans)
a,b,c=map(int,input().split())

if c > a-b:
  print(b+c-q)
else:
  print(0)

### FIXED CODE ###

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

if c > a-b:
  print(b+c-a)
else:
  print(0)
N,H = map(int,input().split())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
B = max(0,H-(A[0]+A[1]))
if B > 0:
    print("No")
else:
    print("Yes")


### FIXED CODE ###

N,H = map(int,input().split())
A = [int(i) for i in input().split()]
B = max(0,N-sum(A))
if B > 0:
    print("No")
else:
    print("Yes")
N, M = map(int, input().split())
vote = list(map(int,input().split()))

votes = sum(vote)
ans = [i for i in L if i * 4 * M >= votes]

if len(ans) >= M:
    print('Yes')
    
else:
    print('No')

### FIXED CODE ###

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

votes = sum(vote)
ans = [i for i in vote if i * 4 * M >= votes]

if len(ans) >= M:
    print('Yes')
    
else:
    print('No')
n = int(input())
A = list(map(int,input().split()))
gcd_list = []
max_element = max(A)

def gcd(a, b):
    while a % b != 0:
        b_next = a % b
        a = b
        b = b_next
    return b

for i in range(n):
    y = A[i]
    for j in range(1, max_element + 1):
        A[i] = j
        x = A[0]
        for k in range(1, n):
            x = gcd(x, A[k])
        gcd_list.append(x)
    A[i] = y
print(max(gcd_list))


### FIXED CODE ###

from math import floor
a, b, t = map(int,input().split())
num = floor(t / a)
print(num * b)
A, B = input().split()
ans = A * B
format(ans, '.0f')

### FIXED CODE ###

def resolve():
    A, B = input().split()
    ans = int(A)*int(B[0])*100+int(A)*int(B[2:])
    print(str(ans)[:-2] if len(str(ans)) >= 3 else "0")
resolve()
A = list(map(int,input().split()))
A.sort()
k = int(input())
ans = sum(A[:2]) + A[3]*(2**k)

### FIXED CODE ###

A = list(map(int,input().split()))
A.sort()
k = int(input())
ans = sum(A[:2]) + A[2]*(2**k)
print(ans)
import sys
def input():
    return sys.stdin.readline()[:-1]
h,w=map(int,input().split())
s=[input() for i in range(h)]
print(40**3)

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# n,w = map(int,input().split()) #n:頂点数　w:辺の数
n=h*w
d = [[float("inf") for i in range(h*w)] for i in range(h*w)]
# print(d)
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(h):
    for j in range(w):
        if i+1<h:
            if s[i][j]!="#" and s[i+1][j]!="#":
                d[i*h+j][(i+1)*h+j]=1
                d[(i+1)*h+j][i*h+j]=1
        if j+1<w:
            if s[i][j]!="#" and s[i][j+1]!="#":
                d[i*h+j][i*h+j+1]=1
                d[i*h+j+1][i*h+j]=1
# for i in range(w):
#     x,y,z = map(int,input().split())
#     d[x][y] = 1
#     d[y][x] = 1
for i in range(h*w):
    d[i][i] = 0 #自身のところに行くコストは０
li=warshall_floyd(d)
ans=0
for i in range(len(li)):
    for j in range(len(li[i])):
        if li[i][j]!=float("inf"):
            ans=max(ans,li[i][j])

print(ans)    

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
h,w=map(int,input().split())
s=[input() for i in range(h)]
# print(40**3)

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# n,w = map(int,input().split()) #n:頂点数　w:辺の数
n=h*w
d = [[float("inf") for i in range(h*w)] for i in range(h*w)]
# print(d)
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(h):
    for j in range(w):
        if i+1<h:
            if s[i][j]!="#" and s[i+1][j]!="#":
                d[i*w+j][(i+1)*w+j]=1
                d[(i+1)*w+j][i*w+j]=1
        if j+1<w:
            if s[i][j]!="#" and s[i][j+1]!="#":
                d[i*w+j][i*w+j+1]=1
                d[i*w+j+1][i*w+j]=1
# for i in range(w):
#     x,y,z = map(int,input().split())
#     d[x][y] = 1
#     d[y][x] = 1
for i in range(h*w):
    d[i][i] = 0 #自身のところに行くコストは０
# print(d)
li=warshall_floyd(d)
ans=0
for i in range(len(li)):
    for j in range(len(li[i])):
        if li[i][j]!=float("inf"):
            ans=max(ans,li[i][j])

print(ans)
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in a:
    ans[i-1]=a.index(i)+1
print(*ans)

### FIXED CODE ###

N =int(input())
if N%2 == 0:
    print(0.5)
else:
    print((N+1)/2/N)
n, m = map(int, input().split())
table = {}
ac = 0
pena_arr = [0 for _ in range(m + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a not in table and b == "AC":
        ac += 1
        table[a] = True
    elif a not in table and b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, m + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)


### FIXED CODE ###

n, m = map(int, input().split())
table = {}
ac = 0
pena = 0
pena_arr = [0 for _ in range(n + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a in table:
        continue
    if b == "AC":
        ac += 1
        table[a] = True
    elif b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, n + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)
=int(input())
a=[]
for i in range(n):
    ai=int(input())
    a.append(ai)
finish=False
for i in range(n):
    if i==0:
        next=a[a[0]-1]
    else:
        next=a[next-1]
    if next==2:
        print(i+2)
        finish=True
        break
if not finish:
    print(-1)

### FIXED CODE ###

n=int(input())
a=[]
for i in range(n):
    ai=int(input())
    a.append(ai)
finish=False
for i in range(n):
    if a[0]==2:
        print(1)
        finish=True
        break
    if i==0:
        next=a[a[0]-1]
    else:
        next=a[next-1]
    if next==2:
        print(i+2)
        finish=True
        break
if not finish:
    print(-1)
import bisect
def main():
    s = input()
    t = input()
    if not set(t).issubset(set(s)):
        return -1
    d = {}
    n = len(s)
    for i, v in enumerate(s):
        if v in d:
            d[v].append(i)
            d[v].append(i + n)
        else:
            d[v] = [i, i+n]
    m = 0
    j = 0
    for i in t:
        ind = bisect.bisect_left(d[i], j)
        m += d[i][ind] - j + 1
        if d[i][ind] > n:
            j = d[i][ind] - n + 1
        else:
            j = d[i][ind] + 1
    return m
print(main())


### FIXED CODE ###

def main():
    s = input()
    t = input()
    if not set(t).issubset(set(s)):
        return -1
    m = 0
    st = s
    for i in t:
        if i in st:
            j = st.index(i)
            m += j + 1
            st = st[j+1:]
        else:
            m += len(st)
            st = s
            j = st.index(i)
            st = st[j+1:]
            m += j + 1
    return m
print(main())
N, K = map(int, input().split())
R = N - K
mod = pow(10, 9) + 7

fact = [0] * N
inv = [0] * N
inv_cal = [0] * N

fact[:2] = [1, 1]
inv[1] = 1
inv_cal[:2] = [1, 1]

for i in range(2, N):
    fact[i] = fact[i-1] * i % mod
    inv[i] = mod - (mod // i) * inv[mod % i] % mod
    inv_cal[i] = inv_cal[i-1] * inv[i] % mod

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * (inv_cal[k] * inv_cal[n-k] % mod) % mod

for k in range(1, K+1):
    if R+1 >= k:
        print(comb(R+1, k) * comb(K-1, k-1) % mod)
    else:
        print(0)

### FIXED CODE ###

N, K = map(int, input().split())
R = N - K
mod = pow(10, 9) + 7

fact = [0] * 2001
inv = [0] * 2001
inv_cal = [0] * 2001

fact[:2] = [1, 1]
inv[1] = 1
inv_cal[:2] = [1, 1]

for i in range(2, 2001):
    fact[i] = fact[i-1] * i % mod
    inv[i] = mod - (mod // i) * inv[mod % i] % mod
    inv_cal[i] = inv_cal[i-1] * inv[i] % mod

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * (inv_cal[k] * inv_cal[n-k] % mod) % mod

for k in range(1, K+1):
    if R+1 >= k:
        print(comb(R+1, k) * comb(K-1, k-1) % mod)
    else:
        print(0)
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    S = SS()

    # 1の塊の長さと位置を調べる
    l = []
    if S[0] == '1':
        l.append(0)
    for i in range(N - 1):
        if S[i] == '0' and S[i+1] == '1':
            l.append(i + 1)
        elif S[i] == '1' and S[i+1] == '0':
            l.append(i + 1)
    if S[-1] == '1':
        l.append(N)
    # print(S)
    # print(l)

    # 1の塊をK+1個くっつけた場合の長さを調べる
    ans = 0
    for i in range(len(l) // 2 - K):
        ans = max(l[2*i+2*K+1] - l[2*i], ans)

    # 端の0を逆立ちさせた場合
    if S[0] == '0':
        ans = max(l[2*K-1], ans)
    if S[-1] == '0':
        ans = max(N - l[len(l)-2*K], ans)
    
    # 全部1だった場合(塊の間も無いし端の0もない)
    if l == [0, N]:
        ans = N

    print(ans)

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    S = SS()

    # 1の塊の長さと位置を調べる
    l = []
    if S[0] == '1':
        l.append(0)
    else:
        l.append(0)
        l.append(0)
    for i in range(N - 1):
        if S[i] == '0' and S[i+1] == '1':
            l.append(i + 1)
        elif S[i] == '1' and S[i+1] == '0':
            l.append(i + 1)
    if S[-1] == '1':
        l.append(N)
    else:
        l.append(N)
        l.append(N)
    # print(S)
    # print(l)

    # 1の塊をK+1個くっつけた場合の長さを調べる
    ans = 0
    if len(l) // 2 - 1 < K:
        ans = N
    else:
        for i in range(len(l) // 2 - K):
            ans = max(l[2*i+2*K+1] - l[2*i], ans)

    # 端の0を逆立ちさせた場合
    # if S[0] == '0':
    #     ans = max(l[2*K-1], ans)
    # if S[-1] == '0':
    #     ans = max(N - l[len(l)-2*K], ans)
    
    # 全部1だった場合(塊の間も無いし端の0もない)
    # if l == [0, N]:
    #     ans = N

    print(ans)

if __name__ == '__main__':
    resolve()
import math
import itertools

n,d = list(map(int, input().split()))
x = [[0 for x in range(2)] for y in range(3)]

for i in range(n):
    x[i] = list(map(int, input().split()))

cnt = 0
for i in itertools.combinations(x, 2):
    y = i[0]
    z = i[1]
    res = 0
    for j in range(d):
        res +=(y[j]-z[j])**2

    res = math.sqrt(res)
    if res.is_integer():
        cnt+=1

print (cnt)


### FIXED CODE ###

import itertools
import math
 
n,d = map(int, input().split())
x = [[0 for x in range(d)] for y in range(n)]

for i in range(n):
    x[i] = list(map(int, input().split()))

cnt = 0
for i in itertools.combinations(x, 2):
    y = i[0]
    z = i[1]
    res = 0
    for j in range(d):
        res +=(y[j]-z[j])**2

    res = math.sqrt(res)
    if res.is_integer():
        cnt+=1

print (cnt)
import math
from decimal import Decimal
a, b, c = map(int, input().split())

if Decimal(c).sqrt() - (Decimal(a).sqrt() + Decimal((b).sqrt())) > 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from decimal import Decimal
a, b, c = map(int, input().split())

if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")
N = int(input())
A = list(map(int, input().split()))
M = min(A)
tmp = 1
if M == 1:
    A.pop(1)
    if 1 in A:
        tmp = 1
    else:
        for i in reversed(range(2,M+1)):
        count = 0
        memo = 0
        for j in range(len(A)):
            if A[j]%i != 0:
                count += 1
                memo = j
                if count > 1:
                    break
        if count <= 1:
            tmp = i
            break
    

else:
    for i in reversed(range(2,M+1)):
        count = 0
        memo = 0
        for j in range(len(A)):
            if A[j]%i != 0:
                count += 1
                memo = j
                if count > 1:
                    break
        if count <= 1:
            tmp = i
            break
        

print(tmp)



### FIXED CODE ###

def gcd(a,b):
    if a <= b:
        a,b = b,a
    if b == 0:
        return a
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

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

L_gcd = [0]*(N+1)
R_gcd = [0]*(N+1)

for i in range(N):
    L_gcd[i+1] = gcd(L_gcd[i],A[i])
    R_gcd[N-i-1] = gcd(R_gcd[N-i],A[N-i-1])

ans = 0
for i in range(N):
    if gcd(L_gcd[i],R_gcd[i+1])>ans:
        ans = gcd(L_gcd[i],R_gcd[i+1])
    
print(ans)
from itertools import accumulate as acc
N, x, *A = map(int, open('0').read().split())
dp = []
for i in range(N):
  dp.append(list(acc((A[(i-j)%N] for j in range(N)),min)))

ans = 10**10
for i,a in enumerate(zip(*dp)):
  ans = min(ans,i*x+sum(a))
print(ans)

### FIXED CODE ###

from itertools import accumulate as acc
N, x, *A = map(int, open(0).read().split())
dp = []
for i in range(N):
  dp.append(list(acc((A[(i-j)%N] for j in range(N)),min)))

ans = 10**60
for i,a in enumerate(zip(*dp)):
  ans = min(ans,i*x+sum(a))
print(ans)
n, m = [int(w) for w in input().split()]
links = [[] for i in range(n + 1)]
ldist = [10 ** 7] * (n + 1)
mark = [10 ** 7] * (n + 1)


def marking(node, dist, parent):
    if dist < ldist[node]:
        ldist[node] = dist
        mark[node] = parent
        for l in links[node]:
            marking(l, dist + 1, node)


for i in range(m):
    a, b = [int(w) for w in input().split()]
    links[a].append(b)
    links[b].append(a)

marking(1, 0, 0)

if 10 ** 7 in mark[2:]:
    print("No")
else:
    print("Yes")
    print("\n".join([str(w) for w in mark[2:]]))


### FIXED CODE ###

from collections import deque

n, m = [int(w) for w in input().split()]
links = [[] for i in range(n + 1)]
mark = [-1] * (n + 1)

for i in range(m):
    a, b = [int(w) for w in input().split()]
    links[a].append(b)
    links[b].append(a)

q = deque([1])
while q:
    now = q.popleft()
    for l in links[now]:
        if mark[l] == -1:
            q.append(l)
            mark[l] = now

if -1 in mark[2:]:
    print("No")
else:
    print("Yes")
    print("\n".join([str(w) for w in mark[2:]]))
a, b, c = map(int, input().aplit())
print(c - (a - b))

### FIXED CODE ###

a, b, c = map(int, input().split())
print(max(0, c - (a - b)))
N = int(input())
l = [list(map(int, input().split())) for i in range(n)]
l.sort(key= x:x[1])
t=0
for i in l:
    a,b=i
    t+=a
    if(t>b):
        print("No")
        break
    else:
        print("Yes")


### FIXED CODE ###

S = input()
n=0
b=0
while n<3 :
    if S[n]==S[n+1]:
        b=1
    n+=1
if b==1:
    print("Bad")
else:
    print("Good")
a,b,k=map(int,input().split())
l=[]
for i in range(1,min(a,b)):
  if a%i==0 and b%i==0:
    l.append(i)
print(l[len(l)-k])
              

### FIXED CODE ###

a,b,k=map(int,input().split())
l=[]
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    l.append(i)
print(l[len(l)-k])
import sys

lines = sys.stdin.readlines()

S = str(lines[0])
X = []

for i in range(len(S)):
  a = int(S[i:])
  c = a-int(a/2019)*2019
  X.append(c)

X.sort()
flag =1
n = 0
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag = flag +1
  else:
    n += int(flag*(flag-1)/2)
    flag = 1
 
print(n)

### FIXED CODE ###

S = str(input())

#10**nのmod計算
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

#左からi文字以降の数字列のmod計算
X = []
a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)
X.sort()
flag =1
n = 0

#modが同じになる組み合わせ、またはもともとmodが0になる数字列の個数の総和計算
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += int(flag*(flag-1)/2)
    flag = 1
n += int(flag*(flag-1)/2)
if X[len(X)-1]==0:
  n +=1
print(n)
#abc164a

a,b,c,d=map(int,input().split())
x=(a+d-1)//d
y=(c+b-1)//b
if x>=y:
 print('Yes')
else:
 print('No')


### FIXED CODE ###

#abc164a

s,w=map(int,input().split())
if s<=w:
 print('unsafe')
else:
 print('safe')
n,k=map(int,input().split())
mod=10**9+7

#x**t%mod
def pow(x,t):
    if t==0:
        return 1
    a=pow(x,t>>1)
    return a*a*(x**(t&1))%mod

#n!%mod
fact=[0]*n
fact[0]=1
for i in range(1,n):
    fact[i]=fact[i-1]*i
    fact[i]%=mod

#1/n!%mod
ifact=[0]*n
ifact[n-1]=pow(fact[n-1],mod-2)
for i in range(n-1,0,-1):
    ifact[i-1]=ifact[i]*i
    ifact[i-1]%=mod


def nCr(n,r):
    if r<0 or r>n:
        return 0
    return fact[n]*ifact[r]*ifact[n-r]%mod


for i in range(1,k+1):
  ans=nCr(k-1,i-1)*nCr(n-k+1,i)
  ans%=mod
  print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
mod=10**9+7

#x**t%mod
def pow(x,t):
    if t==0:
        return 1
    a=pow(x,t>>1)
    return a*a*(x**(t&1))%mod

#n!%mod
fact=[0]*(n+1)
fact[0]=1
for i in range(1,n+1):
    fact[i]=fact[i-1]*i
    fact[i]%=mod

#1/n!%mod
ifact=[0]*(n+1)
ifact[n]=pow(fact[n],mod-2)
for i in range(n,0,-1):
    ifact[i-1]=ifact[i]*i
    ifact[i-1]%=mod


def nCr(n,r):
    if r<0 or r>n:
        return 0
    return fact[n]*ifact[r]*ifact[n-r]%mod


for i in range(1,k+1):
  ans=nCr(k-1,i-1)*nCr(n-k+1,i)
  ans%=mod
  print(ans)
while 1:
    n = int(input())
    if n == 0:
        break
    S = [input() for i in range(n)]

    dup = [0]*n
    for i in range(n):
        for j in range(i+1, n):
            if S[i].find(S[j])+1:
                dup[j] = 1
            if S[j].find(S[i])+1:
                dup[i] = 1
    S = [S[i] for i in range(n) if not dup[i]]
    n -= sum(dup)

    P = [[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            l = len(S[i])
            pos = l
            for k in range(l):
                if S[j].startswith(S[i][k:]):
                    pos = k
                    break
            P[i][j] = pos

    dp = {(1 << i, i): 0 for i in range(n)}
    for state in range(2**n-1):
        for i in range(n):
            if (state >> i) & 1 < 1:
                continue
            for j in range(n):
                if (state >> j) & 1 < 1:
                    dp[state | (1 << j), j] = min(
                            dp.get((state | (1 << j), j), 10**18),
                            dp[state, i] + P[i][j]
                            )
    print(min(dp[2**n-1, i] + len(S[i]) for i in range(n)))

### FIXED CODE ###

while 1:
    n = int(input())
    if n == 0:
        break
    S = [input() for i in range(n)]

    dup = [0]*n
    for i in range(n):
        si = S[i]
        for j in range(i+1, n):
            sj = S[j]
            if si.find(sj)+1:
                dup[j] = 1
            if sj.find(si)+1:
                dup[i] = 1
    S = [S[i] for i in range(n) if not dup[i]]
    n -= sum(dup)

    P = [[0]*n for i in range(n)]
    for i in range(n):
        si = S[i]
        l = len(si)
        for j in range(n):
            sj = S[j]
            pos = l
            for k in range(l):
                if sj.startswith(si[k:]):
                    pos = k
                    break
            P[i][j] = len(sj) - (l - pos)

    ALL = 2**n - 1
    up = 300
    memo = {(ALL, i): 0 for i in range(n)}
    def dfs(state, i):
        if (state, i) in memo:
            return memo[state, i]
        res = up
        for j in range(n):
            if (state >> j) & 1 < 1:
                res = min(res, dfs(state | (1 << j), j) + P[i][j])
        memo[state, i] = res
        return res
    print(min(dfs(1 << i, i) + len(S[i]) for i in range(n)))
N = int(input())
a = list(map(int,input().split()))
total = sum(a)
ans = float('inf')
x = 0
for i in range(N-1):
    x += a[i]
    ans = min(abs(total-2*x),ans)
print (ans)


### FIXED CODE ###

a,b = map(int,input().split())
print ("Possible") if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0 else print ("Impossible")
vote = input("Enter the vote: ")
if 

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int, input().split()))
popular = list(filter(lambda e: e>=(1/(4*m))*sum(a),a))
print("Yes" if len(popular) >= m else "No")
a, b = map(int, input().split())

import math
ans = a*b // math.gcd(a, b)
print(ans)

### FIXED CODE ###

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

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b/gcd(a, b)

print(int(lcm(a, b)))
from sys import stdin
input=stdin.readline
n=int(input().rstrip())
count=0
for i in range(1,n):
    
    for t in range(1,n):
        if n-i*t>0:
            count +=1
        else:
            break
print(count)


### FIXED CODE ###

s=input()
if s[-1]=='s':
    print(s+'es')
else :
    print(s+'s')
import math

x = ((a*math.cos(math.pi/6*(h+m/60))-b*math.cos(math.pi/30*m))**2 + (a*math.sin(math.pi/6*(h+m/60))-b*math.sin(math.pi/30*m))**2 )**(1/2)

print(x)

### FIXED CODE ###

a, b, h, m = [int(e) for e in input().split()]
import math

x = ((a*math.cos(math.pi/6*(h+m/60))-b*math.cos(math.pi/30*m))**2 + (a*math.sin(math.pi/6*(h+m/60))-b*math.sin(math.pi/30*m))**2 )**(1/2)

print(x)