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

K=int(input())
S=input()
mod=10**9+7
def inv(x):
    return pow(x,mod-2,mod)
N=len(S)
ans=0
tmp1=1
tmp2=1
for i in range(0,K+1):
    ans=ans+(tmp1*tmp2)
    ans%=mod
    tmp1=tmp1*25
    tmp1%=mod
    tmp2=tmp2*(inv(i+1)*(N+K-i))
    tmp2%=mod
    #print(tmp1,tmp2)
print(ans)

### FIXED CODE ###

K=int(input())
S=input()
mod=10**9+7
def inv(x):
    return pow(x,mod-2,mod)
N=len(S)
ans=0
tmp1=1
tmp2=1
for i in range(0,K+1):
    ans=ans+(tmp1*tmp2)
    ans%=mod
    tmp1=tmp1*25
    tmp1%=mod
    tmp2=tmp2*(inv(i+1)*(N+K-i))
    tmp2%=mod
    #print(tmp1,tmp2)
print(ans)
### BUGGY CODE ###

import math

num = int(input())
num_sqrt = int(math.sqrt(num))

A = num_sqrt
while num % A != 0:
    A += 1
B = int(num / A)
A, B = str(A), str(B)
ans = max(len(A), len(B))
print(ans)


### FIXED CODE ###

import math

num = int(input())
num_sqrt = int(math.sqrt(num))

ans = 11
for A in range(1, num_sqrt+1):
    if num % A == 0:
        B = int(num / A)
        A, B = str(A), str(B)
        now_ans = max(len(A), len(B))
        ans = min(ans, now_ans)
print(ans)
### BUGGY CODE ###

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

u = set(s)
m = 0
ans = []

for i in u:
    if s.count(i) > m:
        ans = [i]
        m = s.count(i)
    elif s.count(i) == m:
        ans.append(i)

ans.sort()

print('\n'.join(map(str, ans)))
#for i in range(len(ans)):
#    print(ans[i])

        


### FIXED CODE ###

import collections

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

c = collections.Counter(s)
common = c.most_common()

count = common[0][1]
ans = []
for i in common:
  if i[1] == count:
    ans.append(i[0])
  else:
    break
ans.sort()
print(*ans,sep='\n')
### BUGGY CODE ###

import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
# import numpy as np
starttime = time.time()
# import numpy as np
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    # sys.stdout = open("../output.txt", "w")
except:
    pass


s=input()
t=input()
global ans
ans=""
def rec(i,j,x):
    global ans
    if len(x)>len(ans):
        ans=x
    if len(x)+min(abs(i-len(s)),abs(j-len(t)))<len(ans):
        return
    if i>=len(s) or j>=len(t):
        return
    if s[i]==t[j]:
        rec(i+1,j+1,x+s[i])
        return
    rec(i+1,j,x)
    rec(i,j+1,x)
rec(0,0,"")
print("".join(ans))


endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")



### FIXED CODE ###

from subprocess import*
call(('pypy3','-c',"""
s=input()
t=input()
a=len(s)
b=len(t)
dp=[[0]*(b+1) for i in range(a+1)]
for i in range(a):
  for j in range(b):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
res=''
while a!=0 and b!=0:
  if dp[a][b]==dp[a-1][b]:
    a-=1
  elif dp[a][b]==dp[a][b-1]:
    b-=1
  else:
    a-=1
    b-=1
    res=s[a]+res
print(res)
"""))
"""
from subprocess import*
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
# import numpy as np
starttime = time.time()
# import numpy as np
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    # sys.setrecursionlimit(int(pow(10,6)))
    # sys.stdin = open("input.txt", "r")
    # sys.stdout = open("../output.txt", "w")
except:
    pass

"""
### BUGGY CODE ###

import sys
for ab in sys.stdin:
    a,b=map(int,ab.split(" "))
    if a>=b:
        for g in xrange(b,0,-1):
            if a%g==0 and b%g==0:
                gcd = g
                break
        for l in xrange(1,b+1):
            if (a*l)%b == 0:
                lcm = a*l
                break
    else:
        for g in xrange(a,0,-1):
            if a%g==0 and b%g==0:
                gcd = g
                break
        for l in xrange(1,a+1):
            if (b*l)%a == 0:
                lcm = b*l
                break
    print gcd,lcm

### FIXED CODE ###

import sys

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

for ab in sys.stdin:
    a,b=map(int,ab.split(" "))
    if a<=b:
        tmp = a
        a = b
        b = tmp
    g = gcd(a,b)
    l = a*b/g
    print g,l
### BUGGY CODE ###

N, M = map(int, input().split())
S = [list(map(int, input().split())) for i in range(M)]
S2 = [set(range(s[0], s[1] + 1)) for s in S]
S3 = set.intersection(*S2)
print(len(S3))

#ans = set(range(S[0][0], S[0][1] + 1))
#for s in S[1:] :
#    a = set(range(s[0], s[1] + 1))
#    ans = ans & a
#    if len(ans) == 0 :
#        break
#print(len(ans))

### FIXED CODE ###

import collections
N, M = map(int, input().split())
S = [list(map(int, input().split())) for i in range(M)]
smax = max([s[0] for s in S])
smin = min([s[1] for s in S])
if smin - smax + 1 >= 0 :
    print(smin - smax + 1)
else :
    print(0)


#S2 = [set(range(s[0], s[1] + 1)) for s in S]
#S3 = set.intersection(*S2)
#print(len(S3))

#ans = set(range(S[0][0], S[0][1] + 1))
#for s in S[1:] :
#    a = set(range(s[0], s[1] + 1))
#    ans = ans & a
#    if len(ans) == 0 :
#        break
#print(len(ans))
### BUGGY CODE ###

n = int(input())
list = []
for _ in range(n):
    command = input().split()
    if command[0] == 'insert':
        num = int(command[1])
        list.insert(0, num)
    elif command[0] == 'delete':
        num = int(command[1])
        try:
            list.remove(num)
        except:
            pass
    elif command[0] == 'deleteFirst':
        list.pop(0)
    elif command[0] == 'deleteLast':
        list.pop()

print(" ".join(map(str, list)))

### FIXED CODE ###

from collections import deque
import sys

dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()

for i in range(num):

    order = line[i].split()

    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])

print(' '.join(dq))
### BUGGY CODE ###

N,M=map(int,input().split())
X=[0]*N
c=0
for i in range(M):
    L,R=map(int,input().split())
    for j in range(L-1,R):
        X[j]+=1
for i in X:
    if i==M:
        c+=1
print(c)

### FIXED CODE ###

N,M=map(int,input().split())
L=[list(map(int,input().split()))for i in range(M)]
r=N
l=0
for i in range(M):
    l=max(l,L[i][0])
    r=min(r,L[i][1])
if r-l+1<0:
    print(0)
else:
    print(r-l+1)
### BUGGY CODE ###

import numpy as np

def main():
    N, K = map(int, input().split(" "))
    ps = np.array(input().split(" "))
    ps = ps.astype("int64")

    ps_means = np.zeros(N)
    maxval = 0

    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ 2
        if i + 1 >= K:
            a = ps[i-K+1:i+1]
            b = 1 / a
            c = ps_means[i-K+1:i+1] * b
            sumval = np.sum(c)
            if sumval > maxval:
                maxval = sumval

    ans = maxval
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np
 
def main():
    N, K = map(int, input().split(" "))
    ps = np.array(input().split(" "))
    ps = ps.astype("int64")
 
    ps_means = np.zeros(N)
    maxval = 0
 
    for i in range(N):
        ps_means[i] = ((1 + ps[i]) * ps[i])/ 2
        if i + 1 >= K:
            if i + 1 == K:
                sumval = np.sum(ps_means[i-K+1:i+1] / ps[i-K+1:i+1])
            else:
                sumval -= ps_means[i-K] / ps[i-K]
                sumval += ps_means[i] / ps[i]
            if sumval > maxval:
                maxval = sumval
 
    ans = maxval
    print(ans)
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""

N,M=map(int,input().split())
LRD=[list(map(int,input().split())) for i in range(M)]

data=[[] for i in range(N+1)]
for m,(l,r,d) in enumerate(LRD):
    data[l].append([r,d,m])
    data[r].append([l,-d,m])
data2=[set([m[1] for m in data[i]]) for i in range(N+1)]
Mlst=set([i for i in range(M)])

visited=set()
X=[0 for i in range(N+1)]
while Mlst:
    stack=[LRD[Mlst.pop()][0]]
    while stack:
        l=stack.pop()
        visited.add(l)
        for r,d,m in data[l]:
            if not r in visited:
                visited.add(r)
                X[r]=X[l]+d
                stack.append(r)
                if m in Mlst:
                    Mlst.remove(m)
            else:
                if X[r]!=X[l]+d:
                    print("No")
                    exit()

print("Yes")


### FIXED CODE ###

"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""

N,M=map(int,input().split())
LRD=[list(map(int,input().split())) for i in range(M)]

data=[[] for i in range(N+1)]
for m,(l,r,d) in enumerate(LRD):
    data[l].append([r,d,m])
    data[r].append([l,-d,m])
data2=[set([m[1] for m in data[i]]) for i in range(N+1)]
Nlst=set([i for i in range(1,N)])
Mlst=set([i for i in range(M)])
visited=set()
X=[0 for i in range(N+1)]
while Mlst:
    stack=[Nlst.pop()]
    while stack:
        l=stack.pop()
        visited.add(l)
        for r,d,m in data[l]:
            if m in Mlst:
                Mlst.remove(m)
                if not r in visited:
                    visited.add(r)
                    X[r]=X[l]+d
                    stack.append(r)

                else:
                    if X[r]!=X[l]+d:
                        print("No")
                        exit()

print("Yes")
### BUGGY CODE ###

N = int(input())

my_list = [None] * N

for i in range(N):
    s_i = sorted(input())
    my_list[i] = s_i

sum = 0

for i in range(N):
    for j in range(i + 1, N):
        if my_list[i] == my_list[j]:
            sum += 1

print(sum)


### FIXED CODE ###

n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())

jobs = [list(map(int, input().split())) for i in range(n)]
jobs.sort(key=lambda x: (x[0], -x[1]))

reward = 0

for i in range(m):
    rewardful_jobs = [job for job in jobs if job[0] <= i + 1]
    if len(rewardful_jobs) > 0:
        rewardful_jobs.sort(key=lambda x: -x[1])
        reward += rewardful_jobs[0][1]
        jobs.remove(rewardful_jobs[0])

print(reward)


### FIXED CODE ###

import heapq

n, m = map(int, input().split())

# delay, reword
jobs = [list(map(int, input().split())) for i in range(n)]
jobs_days = [[] for i in range(m)]
for job in jobs:
    if job[0] - 1 < m:
        jobs_days[job[0] - 1].append(-job[1])

reward = 0
h = []
heapq.heapify(h)

for i in range(m):
    for job in jobs_days[i]:
        heapq.heappush(h, job)
    if len(h) > 0:
        reward += heapq.heappop(h)

print(-reward)
### BUGGY CODE ###

c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
 
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
 
m = min(b) 
 
def dec():
 
    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i ==0:
                    k +=1
                if k==d:
                    return i
            i -= i//2
        else:
            i -=1
 
 
 
 
                
print(dec())
 

### FIXED CODE ###

c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
 
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
 
m = min(b) 
 
def dec():
 
    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i ==0:
                    k +=1
                if k==len(b):
                    return i
                
            if i == m:
                i -= i//2
                
        i -=1
 
 
 
 
                
print(dec())
### BUGGY CODE ###

sn, tn, qn = map(int, input().split())

sa = []
ta = []
qa = []
for i in range(sn):
    sa.append(int(input()))
for i in range(tn):
    ta.append(int(input()))
for i in range(qn):
    qa.append(int(input()))


def find_nearest(q, al, s, e):
    if e - s < 2:
        if al[s] == q:
            return [al[s], al[s]]
        if al[e] == q:
            return [al[e], al[e]]
        return [al[s], al[e]]
    idx = (e - s) // 2 + s
    if al[idx] == q:
        return [al[idx], al[idx]]
    if al[idx] > q:
        return find_nearest(q, al, s, idx)
    return find_nearest(q, al, idx, e)

def move_cost(q, al, bl):
    a1, a2 = find_nearest(q, al, 0, len(al) - 1)
    b1, b2 = find_nearest(q, bl, 0, len(bl) - 1)

    def calc(x1, x2, x3):
        y1 = min(x1, x2)
        y2 = max(x1, x2)
        if x3 >= y1 and x3 <= y2:
            return abs(x1 - x2)
        return abs(x1 - x2) + abs(x2 - x3)
    return min(
        calc(q, a1, b1),
        calc(q, a1, b2),
        calc(q, a2, b1),
        calc(q, a2, b2),
        calc(q, b1, a1),
        calc(q, b1, a2),
        calc(q, b2, a1),
        calc(q, b2, a2),
    )

for q in qa:
    print(move_cost(q, sa, ta))

### FIXED CODE ###

import bisect
sn, tn, qn = map(int, input().split())

LARGE = -100000000
sa = []
ta = []
qa = []
for i in range(sn):
    sa.append(int(input()))
for i in range(tn):
    ta.append(int(input()))
for i in range(qn):
    qa.append(int(input()))

def find_nearest(q, al, s, e):
    idx = bisect.bisect_right(al, q)
    if idx == 0:
        return [al[0], al[0]]
    if idx == len(al):
        return [al[idx - 1], al[idx - 1]]
    return [al[idx - 1], al[idx]]

def move_cost(q, al, bl):
    a1, a2 = find_nearest(q, al, 0, len(al) - 1)
    b1, b2 = find_nearest(q, bl, 0, len(bl) - 1)

    def calc(x1, x2, x3):
        y1 = min(x1, x2)
        y2 = max(x1, x2)
        if x3 >= y1 and x3 <= y2:
            return abs(x1 - x2)
        return abs(x1 - x2) + abs(x2 - x3)
    return min(
        calc(q, a1, b1),
        calc(q, a1, b2),
        calc(q, a2, b1),
        calc(q, a2, b2),
        calc(q, b1, a1),
        calc(q, b1, a2),
        calc(q, b2, a1),
        calc(q, b2, a2),
    )

for q in qa:
    print(move_cost(q, sa, ta))
### BUGGY CODE ###

from random import randint

D = int(input())
cl = list(map(int, input().split()))
sl = [list(map(int, input().split())) for _ in range(D)]

def score(d, ti, last):
    s = sl[d-1][ti]
    for i in range(len(cl)):
        c = cl[i]
        s -= c*(d-last[i])
    return s

def scores(tl):
    s = 0
    last = [0]*26
    for d in range(D):
        t = tl[d] - 1
        last[t] = d+1
        s += score(d+1,t,last)
    return s


tl = [randint(1,26) for _ in range(D)]
s = scores(tl)
for _ in range(100000):
    d = randint(1,D)
    q = randint(1,26)
    x = tl[d-1]
    tl[d-1] = q
    s2 = scores(tl)
    if s2>s:
        s = s2
    else:
        tl[d-1] = x


for t in tl:
    print(t)



### FIXED CODE ###

D = int(input())
cl = list(map(int, input().split()))
sl = [list(map(int, input().split())) for _ in range(D)]

def score(d, ti, last):
    s = sl[d-1][ti]
    for i in range(len(cl)):
        c = cl[i]
        s -= c*(d-last[i])
    return s

res = []
last = [0]*26
for d in range(D):
    ti = 0
    s = 0
    for t in range(26):
        l = last[t]
        last[t] = d+1
        ss = score(d+1,t,last)
        if ss>s:
            s = ss
            ti = t
        last[t] = l
    last[ti] = d+1
    res.append(ti+1)

for t in res:
    print(t)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

ans = 0
if N >= B-1:
    for i in range(B-1,N,B):
        ans = max(ans, ((A*i)//B) - A * (i//B))

ans = max(ans, ((A*N)//B) - A * (N//B))


print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

ans = 0
if N >= B-1:
    ans = max(ans, ((A*(B-1))//B) - A * ((B-1)//B))
else:
    ans = max(ans, ((A*N)//B) - A * (N//B))


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

import bisect
import sys


def make_primes(n):
    primes = [2]
    for i in range(3, n, 2):
        if all(i % prime != 0 for prime in primes):
            primes.append(i)
    return primes


def make_like2017():
    like2017 = [0]
    for idx in range(1, len(primes)):
        if (primes[idx] + 1) // 2 in primes:
            like2017.append(like2017[idx - 1] + 1)
        else:
            like2017.append(like2017[idx - 1])
    return like2017


def sol(l, r):
    if l == r:
        if l in primes and (l + 1) // 2 in primes:
            return 1
        else:
            return 0

    idx_l = bisect.bisect_left(primes, l)
    idx_r = bisect.bisect_left(primes, r)

    if idx_l == idx_r:
        return 0
    else:
        idx_l = max(0, idx_l - 1)
        idx_r = min(len(like2017s) - 1, idx_r)
        return like2017s[idx_r] - like2017s[idx_l]


N_MAX = 10 ** 5 + 1

Q = int(sys.stdin.readline())
primes = make_primes(N_MAX)
like2017s = make_like2017()

for _ in range(Q):
    l, r = map(int, sys.stdin.readline().split())
    print(sol(l, r))


### FIXED CODE ###

import math
import bisect
  
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def get_like_2017(N):
  nums = set([i for i in range(2,N+1)])
  for i in range(2, int(math.sqrt(N))+1):
    for j in range(2,int(N//i)+1):
      if i*j in nums: nums.remove(i*j)
  
  nums_like_2017 = set([])
  for num in nums:
    if is_prime(int((num+1)/2)) is True:  nums_like_2017.add(num)
  return nums_like_2017

nums_like_2017 = sorted(list(get_like_2017(10**5)))

Q = int(input())
for _ in range(Q):
  l,r = map(int, input().split())
  idx_l = bisect.bisect_left(nums_like_2017, l)
  idx_r = bisect.bisect_right(nums_like_2017, r)
 
  print(idx_r-idx_l)
### BUGGY CODE ###

from collections import defaultdict
from heapq import heappush, heappop
N = int(input())
dic = defaultdict(list)
toNum = {}
L = N*(N-1)//2
s = [0]
for i in range(N-1,0,-1):
  s += [s[-1]+i]
dist = [0]*L
for i in range(N):
  inf = [int(c)-1 for c in input().split()]
  pa = min(i,inf[0])
  pb = max(i,inf[0])
  pnum = s[pa]+(pb-pa-1)
  for j in range(1,N-1):
    a = min(i,inf[j])
    b = max(i,inf[j])
    num = s[a]+(b-a-1)
    dic[pnum]  += [num]
    dist[num] += 1
    pa = a
    pb = b
    pnum = num

hq = []
for i in range(L):
  if dist[i]==0:
    heappush(hq,(1,i))
  dist[i] = 0
if hq==[]:
  print(-1)
  import sys
  sys.exit()
cnt = 0
ans = 0
while hq:
  c, n = heappop(hq)
  if dist[n]>=c:
    continue
  dist[n] = c
  cnt += 1
  for m in dic[n]:
    if dist[m]>=c+1:
      continue
    if ans<c+1:
      ans = c+1
    heappush(hq,(c+1,m))
  if ans>L:
    print(-1)
    break
else:
  print(ans)

### FIXED CODE ###

N = int(input())
es = [[] for i in range(N)]
cand = set()
for i in range(N):
  es[i] = [int(i)-1 for i in input().split()][::-1]
def check(i):
  if es[i]==[]:
    return
  j = es[i][-1]
  if es[j]==[]:
    return
  if es[j][-1]==i:
    cand.add(i)
    cand.add(j)

for i in range(N):
  check(i)
day = 0
while cand:
  day += 1
  precand = cand.copy()
  cand = set()
  for i in precand:
    x = es[i].pop()
  for i in precand:
    check(i)
for i in range(N):
  if len(es[i])!=0:
    print(-1)
    break
else:
  print(day)
### BUGGY CODE ###

N, K, C = [int(i) for i in input().split()]
S = input()
ok_days = []
for ind, s in enumerate(S):
    if(s=='o'):
        ok_days.append(ind+1)

def search(li, ext):
    last = 0
    cnt = 0
    for i in li:
        if(i==ext):
            continue
        if(i>last):
            cnt += 1
            last = i+C
        if(cnt>=K):
            return True
    return False

for cand in ok_days:
    if(not search(ok_days, cand)):
        print(cand)
    

### FIXED CODE ###

N, K, C = [int(i) for i in input().split()]
S = input()
ok_days = []
fdp = []
bdp = []

for ind, s in enumerate(S):
    if(s=='o'):
        ok_days.append(ind+1)

last = 0
fseen = set()
for i in ok_days:
    if(i>last):
        fseen.add(i)
        last = i+C

last = ok_days[-1]+1
bseen = set()
for i in ok_days[::-1]:
    if(i<last):
        bseen.add(i)
        last = i-C

ans = fseen&bseen
if(len(fseen)<=K and len(bseen)<=K):
    for i in sorted(list(ans)):
        print(i)
### BUGGY CODE ###

#!/usr/bin/env python
"""AtCoder Beginner Contest 167: C
https://atcoder.jp/contests/abc167/tasks/abc167_c
"""
import sys
import itertools

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    [N, M, X] = list(map(int, input().split()))

    l = []
    for n in range(N):
        l.append(list(map(int, input().split())))
    # print(l)

    status = [0]*M
    for n in range(N):
        for m in range(M):
            status[m] += l[n][m + 1]
    for v in status:
        if v < X:
            print(-1)
            return
    
    min_cost = sys.maxsize
    for p in itertools.permutations(range(N)):
        # print(p)
        cost = 0
        status = [0]*M
        for n in p:
            cost += l[n][0]
            isCompleted = True
            for m in range(M):
                status[m] += l[n][m + 1]
                if status[m] < X:
                    isCompleted = False
            # print(status)
            if isCompleted:
                # print('fin')
                # print(cost)
                if cost < min_cost:
                    min_cost = cost
                break
    if min_cost == sys.maxsize:
        print(-1)
    else:
        print(min_cost)
            
                    

                # status[m] += l[n][m]
    # for n in range(N):
    #     for m in range(M):
    #         print([n, m])
    # cost = 0
    # status = [[0]*M]*N
    # for n in range(N):
    #     for m in range(M):
    #         print(l[n][m + 1])
    #         # status[n][m] = l[n][m + 1]
    # print(status)

    


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python
"""AtCoder Beginner Contest 167: C - Skill Up
https://atcoder.jp/contests/abc167/tasks/abc167_c
"""

N, M, X = 0, 0, 0
BOOKS = []


def calc_price(book_combinations):
    price = 0
    understandings = [0] * M
    for i in range(len(book_combinations)):
        if book_combinations[i]:
            price += BOOKS[i][0]
            for j in range(len(BOOKS[i][1:])):
                understandings[j] += BOOKS[i][j + 1]
    for u in understandings:
        if u < X:  # couldn't understand
            return -1
    return price


def main():
    global N, M, X, BOOKS
    N, M, X = list(map(int, input().split()))
    BOOKS = [list(map(int, input().split())) for i in range(N)]

    ans = float('inf')
    for i in range(1, 2 ** N):  # => 1: at least one book should be buy
        price = calc_price([(i >> j) & 1 for j in range(N)])
        if 0 < price and price < ans:
            ans = price
    if ans == float('inf'):
        ans = -1
    print(ans)


if __name__ == '__main__':
    main()