Question:
Takahashi, who is a novice in competitive programming, wants to learn M algorithms.
Initially, his understanding level of each of the M algorithms is 0.
Takahashi is visiting a bookstore, where he finds N books on algorithms.
The i-th book (1\leq i\leq N) is sold for C_i yen (the currency of Japan). If he buys and reads it, his understanding level of the j-th algorithm will increase by A_{i,j} for each j (1\leq j\leq M).
However, Takahashi getes tired easily, so he can't read more than 3 books a day.
There is no other way to increase the understanding levels of the algorithms.
Takahashi's objective is to make his understanding levels of all the M algorithms X or higher. Determine whether this objective is achievable. If it is achievable, find the minimum amount of money needed to achieve it.

["N, M, X = list(map(int, input().split()))\nA = [0]*N\n\nfor i in range(N):\n    A[i] = list(map(int, input().split()))\n\nmin_sump = -1\nfor i in range(2**(N+1)):\n    sump = 0\n    sume = [0]*M\n    for j in range(N):\n        ns = \"0\" + str(N) +\"b\"\n        bi = format(i,ns)\n        if bi[-1-j] == \"1\":\n            sump += A[j][0]\n            sume = list(map(sum, zip(sume, A[j][1:])))\n    if all([i >= X for i in sume]):\n        if min_sump == -1:\n            min_sump = sump\n        else:\n            min_sump = min(min_sump,sump)\n\nprint(min_sump)", "N, M, X = [int(i) for i in input().split()]\nCA = []\nfor i in range(N):\n    CA.append([int(j) for j in input().split()])\n#print(CA)\nmcost = 10**10\n\n\nfor i in range(2**N):\n    learn = [0]*M\n    cost = 0\n    bn = str(bin(i))[2:].zfill(N)\n    #print(bn)\n    for j,b in enumerate(bn):\n        if b == \"1\":\n            cost += CA[j][0]\n            for m in range(M):\n                learn[m] += CA[j][m+1]\n                \n    learn.sort()\n    #print(learn)\n    if learn[0] >= X:\n        mcost = min(mcost, cost)\n\nif mcost == 10**10:\n    mcost = -1\n\nprint(mcost)", "n, m, x = map(int, input().split())\ninp=[]\n\n# \u5165\u529b\u3092\u3059\u3079\u3066\u53d7\u3051\u53d6\u308b\nfor i in range(n):\n  tmp = list(map(int, input().split()))\n  inp.append(tmp)\n\n# bit\u5168\u63a2\u7d22\u3092\u884c\u3046\u305f\u3081\u306e\u7bb1\u3065\u304f\u308a\nsum = 0\nmin = 10**10\nfor i in range(2**n):\n  tmp = [0]*m\n  flg = 0\n  \n  # \u3042\u308b\u8cb7\u3046\u8cb7\u308f\u306a\u3044\u306e\u30b1\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u3001\u30d5\u30e9\u30b0\u304c\u7acb\u3063\u3066\u305f\u3089\u30b9\u30ad\u30eb\u30dd\u30a4\u30f3\u30c8\u3092\u5897\u3084\u3059\n  for j in range(n):\n    if ((i >> j) & 1):  # \u9806\u306b\u53f3\u306b\u30b7\u30d5\u30c8\u3055\u305b\u6700\u4e0b\u4f4dbit\u306e\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046\n      sum += inp[j][0]\n      for k in range(1,m+1):\n        #print(n,j, k, tmp, inp)\n        tmp[k-1] += inp[j][k]\n  for ii, k in enumerate(tmp):\n    if k < x: # x\u672a\u6e80\u306a\u3089flg\u3092\u305f\u3066\u3066NG\u3068\u3059\u308b\n      flg = 1\n      break\n  #print(tmp, flg)\n  if sum < min and flg == 0: min = sum\n  sum = 0\n  \nif min == 10**10: min = -1\nprint(min)", "import numpy as np\nN,M,X=map(int,input().split())\n  \nC=[[0 for i in range(M)] for j in range(N)]\nfor i in range(N):\n    #C=[[0 for i in range(M)] for j in range(2**N)]\n    C[i] = list(map(int, input().split()))\n    #print(array)\n    #np.insert(C[i],0,array)\nD=np.array(C)\nE=[0]*2**N\n\nfor i in range(2**N):\n  c=format(i,'012b')\n  for j in range(N):\n    d=int(c[12-N+j])\n    E[i]+=D[j]*int(d)\n#print(E)\n\n#for i in range(2**M):\nif min(E[-1][1:M+1])<X:\n  print(-1);return\n    \nMax=E[-1][0]+1\nMin=Max\nfor i in range(2**N):\n  if min(E[i][1:M+1])>=X:\n    if Min>E[i][0]:Min=E[i][0]\n    continue\n  else:E[i][0]=Max\n#print(E)\nprint(Min)\nreturn", "N, M, X = list(map(int, input().split()))\nC = []\nD = []\nfor _ in range(N):\n    line = list(map(int, input().split()))\n    C.append(line[0])\n    D.append(line[1:])\n\nres = []\nans = []\nfor i in range(2 ** N):\n    score = [0 for _ in range(M)]\n    price = 0\n    for j in range(N):  # \u3053\u306e\u30eb\u30fc\u30d7\u304c\u4e00\u756a\u306e\u30dd\u30a4\u30f3\u30c8\n        if ((i >> j) & 1):  # \u9806\u306b\u53f3\u306b\u30b7\u30d5\u30c8\u3055\u305b\u6700\u4e0b\u4f4dbit\u306e\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046\n            price += C[j]\n            for d in range(M):\n                score[d - 1] += D[j][d]\n    ifPassed = 1\n    for m in range(M):\n        if not score[m] >= X:\n            ifPassed = 0\n            break\n    if ifPassed:\n        ans.append(price)\nif not ans:\n    print((-1))\nelse:\n    print((min(ans)))\n", "n,m,x = map(int,input().split())\nc = [list(map(int,input().split())) for _ in range(n)]\nans = []\n#n\u518a\u306e\u672c\u306b\u304a\u3044\u3066\u8cb7\u3046\u304b\u8cb7\u308f\u306a\u3044\u304b\u306e2\u901a\u308a\u306a\u306e\u30672**n\nfor i in range(2**n):\n    #\u30ea\u30b9\u30c8\u306e\u4e2d\u8eab\u306f\u5024\u6bb51\u3068\u7406\u89e3\u5ea6m\u500b\n    a = [0]*(m+1)\n    com = i\n    for j in range(n):\n        if com >= (2**(n-j-1)):\n            com -= 2**(n-j-1)\n            for k in range(m+1):\n                a[k] += c[j][k]\n    price = a[0]\n    del a[0]\n    if all(a[j]>=x for j in range(m)):\n        #print(price)\n        ans.append(price)\nif len(ans) == 0:\n    print(-1)\nelse:\n    print(min(ans))", "from itertools import combinations\nn,m,x = map(int, input().split())\nca = [list(map(int, input().split())) for _ in range(n)]\n\nans = float(\"inf\")\nfor i in range(1, n+1):\n  for i1 in combinations(ca, i):\n    nums = [0]*(m+1)\n    for i2 in i1:\n      for i3 in range(m+1): nums[i3] += i2[i3]\n    if min(nums[1:]) >= x:\n      if nums[0] < ans: ans = nums[0]\nif ans == float(\"inf\"): print(-1)\nelse: print(ans)", "N,M,X=[int(s) for s in input().split()]\nBook=[[int(s) for s in input().split()] for _ in range(N)]\nINF=10**7\n\nans=set()\nans.add(INF)\n\nfor n in range(2**N):\n  #Bit\u5168\u63a2\u7d22\n  Xls=[0 for i in range(M)]\n  cost=0\n  for i in range(N):\n    if ((n>>i)&1)==1:\n      cost+=Book[i][0]\n      for b in range(M):\n        Xls[b]+=Book[i][b+1]\n    if min(Xls)>=X:\n      ans.add(cost)\nif min(ans)==INF:\n  print(-1)\nelse:\n  print(min(ans))", "N, M, X = map(int, input().split())\nitem = []\nans = []\nfor i in range(N):\n  item.append(list(map(int, input().split())))\nfor i in range(2**N):\n  bag = []\n  money = 0\n  for j in range(N):\n    if ((i>>j) & 1):\n      bag.append(item[j])\n  if bag == []:\n    continue\n  total = [0] * M\n  for k in bag:\n    money += k[0]\n    for l in range(1, M+1):\n      total[l-1] += k[l]\n  if min(total) >= X:\n    ans.append(money)\nif ans == []:\n  print(-1)\nelse:\n  print(min(ans))", "def main():\n    N,M,X = list(map(int,input().split()))\n    ca = [list(map(int,input().split())) for _ in range(N)]\n    \n    mincost = 12*10**5\n    flag = 0\n    for i in range(1,2**N):\n        lev = [0] * M\n        cost = 0\n        a = list(((\"0\"*N)+bin(i)[2:])[-N:])\n        for j in range(N):\n            if a[j] == \"1\":\n                cost +=  ca[j][0]\n                for k in range(M):\n                    lev[k] += ca[j][k+1]\n        if min(lev) >= X:\n            mincost = min(mincost,cost)\n            flag = 1\n    if flag == 0:\n        print((-1))\n    else:\n        print(mincost)\nmain()\n", "from itertools import product\n\nn,m,x = list(map(int, input().split()))\nbook = []\nfor i in range(n):\n    book.append(list(map(int, input().split())))\n\nans = 10 ** 5 * n\nflag = False\nfor i in product([0,1], repeat=n):\n    price = 0\n    skill = [0] * m\n    for index_, bit in enumerate(i):\n        if bit:\n            for j in range(m):\n                skill[j] += book[index_][ j + 1]\n            price += book[index_][0]\n    if all(v >= x for v in skill):\n        ans = min(ans, price)\n        flag = True\nif flag:\n    print(ans)\nelse:\n    print(-1)", "#!/usr/bin/env python3\n\n#import\n#import math\n#import numpy as np\n#= int(input())\n#= input()\nN, M, X = list(map(int, input().split()))\nCA = [list(map(int, input().split())) for _ in range(N)]\nMAX_ANS = 10**9\nans = MAX_ANS\n\nfor i in range(2 ** N):\n    buy = []\n    for j in range(N):\n        if (i >> j) & 1:\n            buy.append(j)\n\n    understand = [0] * (M + 1)\n    money = 0\n    for b in buy:\n        money += CA[b][0]\n        for i in range(1, M + 1):\n            understand[i] += CA[b][i]\n\n    isok = True\n    for i in range(1, M + 1):\n        if understand[i] < X:\n            isok = False\n            break\n\n    if isok:\n        ans = min(ans, money)\n\nif ans == MAX_ANS:\n    print((-1))\nelse:\n    print(ans)\n", "N, M, X = map(int, input().split())\n\n\ndef num2bi(num):\n    l = [0] * N\n    for i in range(N):\n        if num >= 2 ** (N - 1 - i):\n            num -= 2 ** (N - 1 - i)\n            l[i] = 1\n    return l\n\n\nSUM = [0] * M\nA = [[0] * M for _ in range(N)]\nC = []\nfor i in range(N):\n    a = list(map(int, input().split()))\n    for j in range(M):\n        SUM[j] += a[j + 1]\n        A[i][j] = a[j + 1]\n    C.append(a[0])\n\nans = sum(C)\nif min(SUM) < X:\n    ans = -1\nelse:\n    for num in range(2 ** N):\n        SUM = [0] * M\n        tmp = 0\n        for i in range(N):\n            if num2bi(num)[i] == 1:\n                for j in range(M):\n                    SUM[j] += A[i][j]\n                tmp += C[i]\n        if min(SUM) >= X:\n            ans = min(ans, tmp)\n\nprint(ans)", "n,m,x = list(map(int,input().split()))\nca = [list(map(int,input().split())) for _ in range(n)]\n\nsum = 0\nfor i in range(n):\n    sum += ca[i][0]\nans = sum + 1\n\nfor i in range(2**n) :\n    cnt = 0\n    a = [0]*m\n    for j in range(n) :\n        if ((i>>j)&1) :\n            for k in range(m) :\n                a[k] += ca[j][k+1]\n            cnt += ca[j][0]\n    if cnt > 0 and min(a) >= x :\n        ans = min(cnt,ans)\n\nif ans == sum + 1 :\n    print((-1))\nelse :\n    print(ans)\n", "from collections import deque\nfrom copy import deepcopy\nn, m, x = list(map(int, input().split()))\nbooks = [tuple(map(int, input().split())) for _ in range(n)]\nD = deque()\nD.append((-1, 0, [0 for _ in range(m)]))\nans = 10 ** 9\n\nwhile D:\n    num, money, skill = D.popleft()\n    if num == n - 1:\n        if all(s >= x for s in skill):\n            ans = min(ans, money)\n    else:\n        num += 1\n        D.append((num, money, skill))\n        book = books[num]\n        skill = deepcopy(skill)\n        money += book[0]\n        for i, b in enumerate(book[1:]):\n            skill[i] += b\n        D.append((num, money, skill))\n\nprint((ans if ans != 10**9 else -1))\n", "import itertools\nn, m, x = map(int, input().split())\nbooks = []\nfor i in range(n):\n  ins = list(map(int, input().split()))\n  books.append({\"c\": ins[0], \"a\": ins[1: m+1]})\nans = float('inf')\nfor i in range(1, n+1):\n  book_list = list(itertools.combinations(list(range(n)), i))\n  for lis in book_list:\n    cost_sum = 0\n    a_sum = [0] * m\n    ok = 0\n    ok_list = [False] * m\n    for j in lis:\n      cost_sum += books[j]['c']\n      for k in range(m):\n        a_sum[k] += books[j]['a'][k]\n        if not ok_list[k] and a_sum[k] >= x:\n          ok += 1\n          ok_list[k] = True\n    if ok == m and ans > cost_sum:\n      ans = cost_sum\nif ans == float('inf'):\n  print(-1)\nelse:\n  print(ans)", "n, m, x = map(int, input().split())\nc = []\na = []\nfor i in range(n):\n  inp = list(map(int, input().split()))\n  c_, a_ = inp[0], inp[1:]\n  c.append(c_)\n  a.append(a_)\n\nans = float('inf')\nfor bit in range(1<<n):\n  cost = 0\n  skill = [0]*m\n  for i in range(n):\n    if bit & 1<<i:\n      cost += c[i]\n      for j in range(m):\n        skill[j] += a[i][j]\n  if min(skill) >= x:\n    ans = min(ans, cost)\n\nif ans == float('inf'):\n  print(-1)\nelse:\n  print(ans)", "N,M,X = map(int,input().split())\nC = []\nA = []\nfor i in range(N):\n    a = [int(i) for i in input().split()]\n    C.append(a[0])\n    del a[0]\n    A.append(a)\nans = M * (10**5) + 1\nfor i in range(2**N):\n    bi = format(i,\"b\")\n    bistr = str(bi)\n    P = [\"0\"]*N\n    Q = [0]*M\n    m = 0\n    for j in range(len(bistr)):\n        P[-1-j] = bistr[-1-j]\n    for j in range(N):\n        if(P[j] == \"1\"):\n            m += C[j]\n            for k in range(M):\n                Q[k] += A[j][k]\n    count = 0\n    for j in range(M):\n        if(Q[j] >= X):\n            count += 1\n        if(count >= M):\n            ans = min(ans,m)\nif(ans >= M * (10**5) + 1):\n    print(-1)\n    return\nprint(ans)", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nimport numpy as np\ndef main():\n    n, m, x = list(map(int, input().split()))\n    data = np.array(read().split(), np.int64)\n    data = data.reshape(n, -1) # data\u3092n\u884c\u306b\u6574\u5f62\n    cost_per_cost = data[:, 0] # data\u5168\u884c\u306e0\u5217\n    effect_per_book = data[:, 1:]\n\n    costs = np.zeros(2**n, np.int64)\n    # ability \u884c\u6570\uff1a2**n(\u672c\u306e\u7d44\u307f\u5408\u308f\u305b\u30d1\u30bf\u30fc\u30f3), \u5217\u6570\uff1a\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306e\u6570\n    ability = np.zeros((2**n, m), np.int64)\n    for i in range(n):\n        costs[1<<i:1<<(i+1)] = costs[:1<<i] + cost_per_cost[i]\n        ability[1<<i:1<<(i+1)] = ability[:1<<i] + effect_per_book[i]\n    ok = np.all(ability >= x, axis=1)\n    res = costs[ok]\n    if len(res) == 0:\n        print((-1))\n    else:\n        print((res.min()))\n\ndef __starting_point():\n    main()\n\n\n__starting_point()", "from itertools import product\n\nn, m, x = map(int, input().split())\nCA = [list(map(int, input().split())) for _ in range(n)]\n\ncost = -1\nfor cand in product((0, 1), repeat=n):\n  tmp = 0\n  scores = [0] * m\n  for bought, ca in zip(cand, CA):\n    if not bought:\n      continue\n    for i in range(1, m + 1):\n      scores[i - 1] += ca[i]\n    tmp +=  ca[0]\n  if min(scores) >= x and (cost == -1 or tmp < cost):\n    cost = tmp\nprint(cost)", "N,M,X = list(map(int,input().split()))\nB=[0]*N\nfor i in range(N):\n    B[i]=list(map(int, input().strip().split()))\n\nx=N*10**10\nsum_ok = N*10**10\nunst =[0]*M\nflg=0\n\ndef all0(v):\n    return 0\n\n\nfor i in range(2**N):\n    # print(bin(i))\n    sum = 0\n    unst = list(map(all0,unst))\n    for j in range(N):\n        if (i >> j) & 1 :\n            # print(j)\n            sum += B[j][0]\n            # unst = list(map(lamda:x,x+B[j][]))\n            for k in range(M):\n                unst[k]+=B[j][k+1]\n    # print(unst)\n    # print(\"sum=\",sum)\n    if all(elem >= X for elem in unst):\n        sum_ok = sum\n        flg=1\n    x=min(x,sum_ok)\n    # print(x)\n        \n# print(unst)\n\nif flg==0:\n    print((-1))\nelse:\n    print(x)\n        \n        \n", "n, m, x = list(map(int, input().split()))\ncl = list(list(map(int, input().split())) for _ in range(n))\n\nans = float('inf')\nfor i in range(2**n):\n    tmp = [0]*m\n    cost = 0\n    for j in range(n):\n        if (i >> j) & 1:\n            for k in range(m):\n                tmp[k] += cl[j][k+1]\n            cost += cl[j][0]\n    for t in tmp:\n        if t < x:\n            break\n    else:\n        ans = min(ans, cost)\n\nif ans == float('inf'):\n    print((-1))\nelse:\n    print(ans)\n", "n,m,x = map(int,input().split())\nc = list(list(map(int,input().split())) for _ in range(n))\nans = 10**7\nfor i in range(1<<n):\n    mokuhyo = [0]*m\n    cost = 0\n    for j in range(n):\n        if i>>j&1:\n            for r in range(m):\n                mokuhyo[r] += c[j][r+1]\n            cost += c[j][0]\n    if all(k>=x for k in mokuhyo):\n        ans = min(ans, cost)\nprint(\"-1\" if ans == 10**7 else ans)        ", "N, M, X = list(map(int, input().split()))\nC = []\nA = []\nfor _ in range(N):\n    l = list(map(int, input().split()))\n    C.append(l[0])\n    A.append(l[1:])\n\nans = -1\nfor i in range((1<<N)):\n    u = [0] * M\n    p = 0\n    for j in range(N):\n        if i & (1 << j):\n            p += C[j]\n            for k in range(M):\n                u[k] += A[j][k]\n    if min(u) >= X:\n        if ans == -1 or ans > p:\n            ans = p\nprint(ans)\n\n", "N, M, X = [int(_) for _ in input().split()]\nA = []\nC = []\nfor _ in range(N):\n    c, *a = [int(_) for _ in input().split()]\n    A.append(tuple(a))\n    C.append(c)\n\nans = 10 ** 10\nfor i in range(2 ** N):\n    v = [0 for _ in range(M)]\n    c = 0\n    for j in range(N):\n        if i & 1 << j:\n            for k, a in enumerate(A[j]):\n                v[k] += a\n            c += C[j]\n    if min(v) >= X:\n        ans = min(ans, c)\n\nif ans == 10 ** 10:\n    print((-1))\nelse:\n    print(ans)\n", "import numpy as np\n\n\ndef main() -> None:\n    n, m, x = list(map(int, input().split()))\n    books = [tuple(map(int, input().split())) for _ in range(n)]\n\n    is_able = False\n    answer = float('inf')\n    for i in range(2**n):\n        money = 0\n        skills = np.zeros(m)\n        for j in range(n):\n            if ((i >> j) & 1):\n                money += books[j][0]\n                skills += books[j][1:]\n        if x <= skills.min():\n            is_able = True\n            answer = min(answer, money)\n\n    print((answer if is_able else -1))\n    return\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "import numpy as np\nn,m,x = list(map(int,input().split()))\nc = []\na = []\n\nfor i in range(n):\n  stdIn = list(map(int,input().split()))\n  c.append(stdIn[0])\n  a.append(stdIn[1:])\nflag = 0\nans = sum(c)\nfor i in range(2**n):\n  result = np.array([0]*m)\n  price = 0\n  for j in range(n):\n    if((i>>j)&1):\n      result += a[j]\n      price += c[j]\n  if (len(result[result<x])==0):\n    ans = min(ans,price)\n    flag = 1\nprint(ans if flag != 0 else -1)", "n,m,x = map(int, input().split())\nc = [list(map(int, input().split())) for _ in range(n)]\nprices = []\nfor i in range(2**n):\n  buy = [[] for _ in range(m+1)]\n  for j in range(n):\n    if ((i >> j) & 1):\n      for k in range(m+1):\n        buy[k].append(c[j][k])\n  for k in range(1,m+1):\n    if sum(buy[k]) < x:\n      break\n  else:\n    prices.append(sum(buy[0]))\nif len(prices) == 0:\n  print(-1)\nelse:\n  print(min(prices))", "from operator import add\n\nN,M,X = map(int,input().split())\nC = []\nA = []\n\nfor i in range(N):\n    T = list(map(int,input().split()))\n    C.append(T[0])\n    A.append(T[1:])\n\nans = 100000000\n\n\nfor i in range(2**N):\n    ex = [0]*M\n    cost = 0\n    Flag = True\n    for j in range(N):\n        if((i >> j) & 1):\n            ex = list(map(add,ex,A[j]))\n            cost += C[j]\n    \n    for k in range(M):\n        if not ex[k] >= X:\n            Flag = False\n    \n    if Flag:\n        if cost <= ans:\n            ans = cost\n\n\nif ans == 100000000:\n    print(-1)\nelse:\n    print(ans)", "#\u4ed6\u306e\u4eba\u306e\u56de\u7b54\nn, m, x = map(int, input().split())\nca = [list(map(int,input().split())) for _ in range(n)]\n\nadd = []\n\nfor i in range(2**n):\n    skill = [0]*(m+1)\n    for j in range(n):\n        if ((i>>j) & 1):\n            skill = list(map(sum, zip(skill, ca[j])))\n    if min(skill[1:])>=x:\n        add.append(skill)\n\nif add:\n    add.sort()\n    print(add[0][0])\nelse:\n    print(-1)", "n,m,x = map(int,input().split())\nbooks = [list(map(int,input().split())) for _ in range(n)]\nans = 12 * (10**5) + 1\nfor i in range(2**n):\n    kingaku = 0\n    rikaido = [0] * m\n    for j in range(n):\n        if (i >> j) & 1:\n            kingaku += books[j][0]\n            for k in range(m):\n                rikaido[k] += books[j][k+1]\n    if all((a >= x for a in rikaido)):\n        ans = min(ans,kingaku)\nif ans != 12 * (10**5) + 1:\n    print(ans)\nelse:\n    print(\"-1\")", "N, M, X = list(map(int, input().split()))\nC = []\nA = []\n\nfor i in range(N):\n    tmp = list(map(int, input().split()))\n    C.append(tmp[0])\n    A.append(tmp[1:])\n\nans = -1\n\nfor i in range(1, 1 << N):\n    price = 0\n    skill = [0] * M\n    b = len(bin(i)) - 2\n    for j in range(b):\n        price += C[j] * (i >> j & 1)\n        for k in range(M):\n            skill[k] += A[j][k] * (i >> j & 1)\n\n    if min(skill) >= X and (price < ans or ans < 0):\n        ans = price\n\nprint(ans)\n", "import numpy as np\nN,M,X = map(int, input().split())\nbooks = []\nfor i in range(N):\n  tmp_book = list(map(int, input().split()))\n  books.append(tmp_book)\n\nans = 10**10\nfor i in range(1,2**(N)):\n  flag = 1\n  ability = np.zeros(M)\n  money = 0\n  \n  tmp = str(bin(i))\n  tmp = '0'*(N-len(tmp[2:])) + tmp[2:]\n  for j in range(N):\n    if tmp[j] == '1':\n      ability += books[j][1:]\n      money += books[j][0]\n  for j in range(M):\n    if ability[j] < X:\n      flag = 0\n      break\n  if flag == 1:\t\tans = min(ans, money)\nif ans == 10**10:\tprint(-1)\nelse:\t\t\t\tprint(ans)", "N,M,X = map(int,input().split())\na = [list(map(int,input().split())) for i in range(N)]\nd = []\nfor i in range(2**N):\n    b = [0] * (M+1)\n    e = i\n    for j in range(N):\n        if e >= (2**(N-j-1)) :\n            e -= (2**(N-j-1))\n            for k in range(M+1):\n                b[k] += a[j][k]\n    c = 1\n    for j in range(1,M+1):\n        if b[j] < X:\n            c = 0\n            break\n    if c == 1:\n        d.append(b[0])\nif len(d) > 0:\n    ans = min(d)\nelse:\n    ans = -1\nprint(ans)", "n, m, x = map(int, input().split())\ninp=[]\n\n# \u5165\u529b\u3092\u3059\u3079\u3066\u53d7\u3051\u53d6\u308b\nfor i in range(n):\n  tmp = list(map(int, input().split()))\n  inp.append(tmp)\n\n# bit\u5168\u63a2\u7d22\u3092\u884c\u3046\u305f\u3081\u306e\u7bb1\u3065\u304f\u308a\nsum = 0\nmin = 10**10\nfor i in range(2**n):\n  tmp = [0]*m\n  flg = 0\n  \n  # \u3042\u308b\u8cb7\u3046\u8cb7\u308f\u306a\u3044\u306e\u30b1\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u3001\u30d5\u30e9\u30b0\u304c\u7acb\u3063\u3066\u305f\u3089\u30b9\u30ad\u30eb\u30dd\u30a4\u30f3\u30c8\u3092\u5897\u3084\u3059\n  for j in range(n):\n    if ((i >> j) & 1):  # \u9806\u306b\u53f3\u306b\u30b7\u30d5\u30c8\u3055\u305b\u6700\u4e0b\u4f4dbit\u306e\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046\n      sum += inp[j][0]\n      for k in range(1,m+1):\n        #print(n,j, k, tmp, inp)\n        tmp[k-1] += inp[j][k]\n  for ii, k in enumerate(tmp):\n    if k < x: # x\u672a\u6e80\u306a\u3089flg\u3092\u305f\u3066\u3066NG\u3068\u3059\u308b\n      flg = 1\n      break\n  #print(tmp, flg)\n  if sum < min and flg == 0: min = sum\n  sum = 0\n  \nif min == 10**10: min = -1\nprint(min)", "from itertools import product\n\nn, m, x = map(int, input().split())\n\nCA = [list(map(int, input().split())) for _ in range(n)]\n\nans = 10**12+1\nfor t in product([0,1], repeat=n): # (1, 0, 0)\n    cost = 0\n    understanding = [0] * m\n    for i, b in enumerate(t):\n        if b == 1:\n            cost += CA[i][0]\n            for j, a in enumerate(CA[i][1:]):\n                understanding[j] += a  \n    if sum(True for u in understanding if u >= x) == m:\n        ans = min(ans, cost)\n\nif ans == 10**12+1:\n    print(-1)\nelse:\n    print(ans)", "import sys\nimport math\nfrom collections import defaultdict, deque, Counter\nfrom copy import deepcopy\nfrom bisect import bisect, bisect_right, bisect_left\nfrom heapq import heapify, heappop, heappush\n    \ninput = sys.stdin.readline\ndef RD(): return input().rstrip()\ndef F(): return float(input().rstrip())\ndef I(): return int(input().rstrip())\ndef MI(): return map(int, input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int, input().split()))\ndef TI(): return tuple(map(int, input().split()))\ndef LF(): return list(map(float,input().split()))\ndef Init(H, W, num): return [[num for i in range(W)] for j in range(H)]\n    \n    \ndef main():\n    N, M, X = MI()\n    res = float('inf')\n    D = Init(2**N, M, 0)\n    C = defaultdict(int)\n    L = [LI() for i in range(N)]\n    for i in range(2**N):\n        for j in range(N):\n            if i >> j & 1 == 1 or C[i | 1 << j] > 0:\n                continue\n            for index, n in enumerate(L[j][1:]):\n                D[i | 1 << j][index] = D[i][index] + n\n            C[i | 1 << j] = C[i]+L[j][0]\n    for i in range(1, 2**N):\n        temp = D[i]\n        ans = True\n        for j in temp:\n            if j < X:\n                ans = False\n                break\n        if ans:\n            res = min(res, C[i])\n    if res == float('inf'):\n        print(-1)\n    else:\n        print(res)\n            \n            \n        \n\n\n\n\ndef __starting_point():\n    main()\n__starting_point()", "n,m,x = map(int,input().split())\ncost = []\ncont = []\nfor i in range(n):\n  c,*a = map(int,input().split())\n  cost.append(c)\n  cont.append(a)\n\nans = 10**9\nfor bit in range(1<<n):\n  cnt = 0\n  skills = [0]*m\n  for i in range(n):\n    if (bit>>i) & 1:\n      cnt += cost[i]\n      for j,pts in enumerate(cont[i]):\n        skills[j] += pts\n  if min(skills)>=x:\n    ans = min(ans, cnt)\nprint(ans if ans<10**9 else -1)", "nb,na,level = list(map(int , input().split()))\nblevels = []\nfor i in range(nb):\n    blevels.append(list(map(int , input().split())))\nans = float('inf')\n#print(ans)\nfor i in range(1,2**nb):\n    flag = 0\n    levels_sum = [0]*na\n    price_sum = 0\n    for j in range(nb):\n        if((1<<j) & i > 0):\n            price_sum += blevels[j][0]\n            for k in range(1,na+1):\n                levels_sum[k-1] += blevels[j][k]\n    #print(price_sum)\n    #print(*levels_sum)\n    for levels in levels_sum:\n        if(levels < level):\n         #   print(\"breaked\")\n            flag = 1\n            break\n    if(flag == 0 and ans > price_sum):\n        ans = price_sum\n        #print(ans)\nif(ans != float('inf')):\n    print(ans)\nelse:\n    print(\"-1\")\n", "N, M, X = map(int, input().split())\nC = []\nA = []\nfor _ in range(N):\n    l = list(map(int, input().split()))\n    C.append(l[0])\n    A.append(l[1:])\n \nans = -1\nfor i in range((1<<N)):\n    u = [0] * M\n    p = 0\n    for j in range(N):\n        if i & (1 << j):\n            p += C[j]\n            for k in range(M):\n                u[k] += A[j][k]\n    if min(u) >= X:\n        if ans == -1 or ans > p:\n            ans = p\nprint(ans)", "\nurl = \"https://atcoder.jp//contests/abc160/tasks/abc160_c\"\n\nimport itertools\n\n\ndef main():\n    n, m , X = list(map(int, input().split()))\n    books = []\n    ans = -1\n    for _ in range(n):\n        books.append(list(map(int, input().split())))\n    for i in range(n):\n        for row in itertools.combinations(list(range(0, n)), i+1):\n            cost = 0\n            rikai = [0] * m\n            for idx in row:\n                cost += books[idx][0]\n                for idx2 in range(1, len(books[idx])):\n                    rikai[idx2 - 1] += books[idx][idx2]\n                if len(list([x for x in rikai if x >= X])) == len(rikai):\n                    ans = min(ans, cost) if ans != -1 else cost\n    print(ans)\n\n\n\n\n\n\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "from itertools import combinations\nimport numpy as np\nn,m,x = map(int, input().split())\ncosts = []\nunderstnding = []\nans = 10 ** 20\n\nfor _ in range(n):\n    tmp = list(map(int, input().split()))\n    costs.append(tmp[0])\n    understnding.append(tmp[1:])\n    \ncosts = np.array(costs)\nunderstnding = np.array(understnding)\n\nfor i in range(1, 2**n):\n    row = str(bin(i)).split(\"0b\")[1]\n    row = '0'*(n - len(row))+row\n    one_index = [j for j in range(len(row)) if row[j] ==\"1\"]\n    cost_sum = np.sum(costs[one_index])\n    under_sum = np.sum(understnding[one_index], axis=0)\n    if np.all(under_sum >= x) and cost_sum < ans:\n        ans = cost_sum\n    \nif ans == 10 ** 20:\n    print(-1)\nelse:\n    print(ans)", "N,M,X=[int(s) for s in input().split()]\nBook=[[int(s) for s in input().split()] for _ in range(N)]\nINF=10**7\n\nans=set()\nans.add(INF)\n#\u6df1\u3055\u512a\u5148\u63a2\u7d22\ndef DFS(n,cost,Xls):\n  if n==N:\n    if min(Xls)>=X:\n      ans.add(cost)\n  else:\n    Xnext=[Xls[i]+Book[n][i+1] for i in range(M)]\n    DFS(n+1,cost+Book[n][0],Xnext)\n    DFS(n+1,cost,Xls)\n\nDFS(0,0,[0 for _ in range(M)])\nif min(ans)==INF:\n  print(-1)\nelse:\n  print(min(ans))", "n,m,r = map(int,input().split())\nbooks = [[int(i) for i in input().split()] for _ in range(n)]\nt = []\n\nfor x in range(2**n):\n    p = [0]*(m+1)\n    for y in range(n):\n        if (x>>y)&1 :\n            p = [a+b for (a,b) in zip(books[y],p)]\n    t.append(p)\n\n\n\n\nans = []\n\n\nc = True\n\nfor z in t:\n    c = True\n    for s in range(1,m+1):\n        if z[s] < r:\n            c = False\n    if c:\n        ans.append(z[0])\n\nif ans != []:\n    print(min(ans))\n\nelse:\n    print(-1)", "N, M, X = list(map(int, input().split()))\nlis = []\n\nfor i in range(N):\n    CA = list(map(int, input().split()))\n    lis.append(CA)\n\nans = 1e9\nfor i in range(2 ** N):\n    check = [0 for i in range(M + 1)]\n    for j in range(N):\n        if i >> j & 1:\n            for k in range(M + 1):\n                check[k] += lis[j][k]\n        if min(check[1:]) >= X:\n            ans = min(ans, check[0])\nif ans == 1e9:\n    print((-1))\nelse:\n    print(ans)\n", "#ABC167\nN,M,X=map(int,input().split())\nc = []  #\u53c2\u8003\u66f8\u306e\u5024\u6bb5\na = []  #\u5404\u53c2\u8003\u66f8\u306b\u5165\u308b\u7406\u89e3\u5ea6\nfor i in range(N):\n    c_temp, *a_temp = list(map(int, input().split()))  # \u3053\u3046\u3059\u308b\u3068\u30012\u3064\u76ee\u4ee5\u964d\u3092\u30ea\u30b9\u30c8\u3067\u53d7\u3051\u53d6\u308c\u308b\n    c.append(c_temp)\n    a.append(a_temp)\nprice_min = 10000000\nfor i in range(2**N):\n    price_total = 0  #\u5024\u6bb5\u306e\u5408\u8a08\n    learn_total = [0] * M #\u7406\u89e3\u5ea6\u306e\u5408\u8a08\n    for j in range(N):\n        if (i >> j) & 1:  # j\u6841\u76ee\u304c0\u304b1\u304b\u898b\u3066\u3001j\u518a\u76ee\u3092\u8cb7\u3046\u304b\u8cb7\u308f\u306a\u3044\u304b\u5224\u5b9a\u3057\u307e\u3059\n            price_total += c[j]  # \u8cb7\u3046\u306e\u3067\u3001j\u518a\u76ee\u306e\u5024\u6bb5\u3092\u52a0\u7b97\u3057\u307e\u3059\n            learn = a[j]  # \u300cj\u518a\u76ee\u306e\u53c2\u8003\u66f8\u3092\u8aad\u3093\u3067\u5897\u3048\u308b\u3001\u5404\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306e\u7406\u89e3\u5ea6\u300d\u306e\u30ea\u30b9\u30c8\u3067\u3059\n            for k, la in enumerate(learn):  # \u7406\u89e3\u5ea6\u3092\u52a0\u7b97\u3057\u307e\u3059 enumerate\u3092\u4f7f\u3046\u3068\u3001range(n)\u3088\u308a\u30b9\u30de\u30fc\u30c8\u3067\u3059\n                learn_total[k] += la\n    if all(learn_total[k] >= X for k in range(M)):\n        if price_min > price_total:\n            price_min=price_total\n            \nif price_min==10000000:\n    print (-1)\nelse:\n    print (price_min)", "import numpy as np\nN,M,X = map(int,input().split())\nC = []\nA = []\nfor _ in range(N):\n    l = list(map(int,input().split()))\n    C.append(l[0])\n    A.append(np.array(l[1:]))\nans = 10**100\nfor i in range(2**N):\n    rikaido = np.zeros(M)\n    c = 0\n    for j in range(N):\n        if (i >> j) & 1:\n            c += C[j]\n            rikaido += A[j]\n    if all([x >= X for x in rikaido]):\n        ans = min(ans, c)\nprint(ans if ans != 10**100 else -1)", "n, m, x = list(map(int, input().split()))\nans = 10 ** 9\nbooks = [tuple(map(int, input().split())) for _ in range(n)]\nfor i in range(2 ** (n + 1)):\n    skill = [0 for _ in range(m)]\n    money = 0\n\n    for j in range(n):\n        if i >> j & 1:\n            book = books[j]\n            money += book[0]\n            for k, b in enumerate(book[1:]):\n                skill[k] += b\n    if all(s >= x for s in skill):\n        ans = min(ans, money)\nprint((ans if ans != 10 ** 9 else - 1))\n", "def main():\n    n, m, x = list(map(int, input().split()))\n    sofar = 10 ** 5 + 1\n    cl = list(list(map(int, input().split())) for _ in range(n))\n    # print(cl)\n    ans = float('inf')\n    for i in range(2 ** n):\n        tmp = [0] * m\n        cost = 0\n        for j in range(n):\n            # print(bin(j), i, bin(i >> j))\n            if (i >> j) & 1:\n                for k in range(m):\n                    tmp[k] += cl[j][k + 1]\n                cost += cl[j][0]\n                # print(tmp)\n        for t in tmp:\n            if t < x:\n                break\n        else:\n            ans = min(ans, cost)\n    if ans == float('inf'):\n        return -1\n    else:\n        return ans\n\n\ndef __starting_point():\n    print((main()))\n\n__starting_point()", "N, M, X = map(int, input().split(' '))\nA, C = [], []\nfor n in range(N):\n  inp = list(map(int, input().split(' ')))\n  C.append(inp[0])\n  A.append(inp[1:])\n  \ndef proceed_step(remained, current_cost, n):\n  nonlocal N, X\n  remained_next = []\n  \n  if not remained: return current_cost\n  if n == N: return float('inf')\n  \n  for algorithm in remained:\n    m, current_sum = algorithm[0], algorithm[1]\n    current_sum += A[n][m]\n    if current_sum < X:\n      remained_next.append([m, current_sum])\n      \n  return min(proceed_step(remained, current_cost, n+1),\n             proceed_step(remained_next, current_cost + C[n], n+1))\n\nremained = [[m, 0] for m in range(M)]\ntotal_cost = proceed_step(remained, current_cost=0, n=0)\nif total_cost == float('inf'): print(-1)\nelse: print(total_cost)", "import numpy as np\nn,m,x = map(int, input().split())\nli = []\nfor i in range(n):\n    c_A = list(map(int, input().split()))\n    li.append(c_A)\n\nli = np.array(li)\ncost = 10**7\nfor i in range(2**n):\n    c_s = np.array([0]*(m+1))\n    for j in range(n):\n        if ((i>>j)&1):\n            c_s += li[j]\n    if np.all(c_s[1:]>=x):\n        cost = min(cost,c_s[0])\nif cost==10**7:\n    print(-1)\nelse:\n    print(cost)", "n, m, x = list(map(int, input().split()))\nca = [list(map(int, input().split())) for _ in range(n)]\n\ndef binary(i, cost, und):\n    if i==n:\n        for j in range(m):\n            if und[j]<x:\n                return float('inf')\n        return cost\n\n    left = binary(i+1, cost, und)\n    right = binary(i+1, cost+ca[i][0], [und[k] + ca[i][k+1] for k in range(m)])\n\n    mi = min(left, right)\n\n    return mi\n\nans = binary(0, 0, [0]*m)\nif ans == float('inf'):\n    print((-1))\nelse:\n    print(ans)\n", "N,M,X=map(int,input().split())\n\nC=[]\nA=[]\nfor i in range(N):\n    t=list(map(int,input().split()))\n    C.append(t[0])\n    A.append(t[1:])\n\nans=-1\nfor i in range(1<<N):     #range(0,2^N)\u3000\u5de6\u30d3\u30c3\u30c8\u30b7\u30d5\u30c8\n    A_sum=[0]*M             #t=[0 0 0]\u306a\u3069 len(t)=M\n    C_sum=0\n    for j in range(N):\n        if (i>>j)&1==0:   #j\u306e\u30d5\u30e9\u30b0\u304c\u306a\u3044\u3068\u304d\n            continue\n        C_sum+=C[j]               #\u5408\u8a08\u306e\u5024\u6bb5\n        for k in range(M):\n            A_sum[k]+=A[j][k]     #\u5408\u8a08\u306e\u7406\u89e3\u5ea6  \n    if all(x>=X for x in A_sum):  #t\u306e\u3059\u3079\u3066\u306e\u8981\u7d20\u304cX\u3088\u308a\u5927\u304d\u3044\u3068\u304d\n        if ans==-1:\n            ans=C_sum\n        else:\n            ans=min(ans,C_sum)\nprint(ans)", "N,M,X=map(int,input().split())\nL=[list(map(int,input().split())) for i in range(N)]\na=2**N\nJ=[]\nfor i in range(a):\n    T=True\n    K=[0]*(M+1)\n    for j in range(N):\n        if (i>>j)&1:\n            for k in range(M+1):\n                K[k]+=L[j][k]\n    for j in range(1,M+1):\n        if K[j]<X:\n            T=False\n    if T:\n        J.append(K[0])\nif len(J)==0:\n    print(-1)\nelse:\n    J.sort()\n    print(J[0])", "import itertools as it\n\nN,M,X=map(int,input().split())\nbook = [[int(_) for _ in input().split()] for i in range(N)]\n\ncombs = it.product([0, 1], repeat=N)\nprices = []\nfor comb in combs:\n\tbag = [0] * (M+1)\n\tfor i in range(N):\n\t\tif comb[i] == 0:\n\t\t\tcontinue\n\t\telse:\n\t\t\tfor j in range(M+1):\n\t\t\t\tbag[j]+=book[i][j]\n\tif min(bag[1:]) < X:\n\t\tcontinue\n\telse:\n\t\tprices.append(bag[0])\n\nif len(prices) == 0:\n\tprint(-1)\nelse:\n\tprint(min(prices))", "def i_input(): return int(input())\n\n\ndef i_map(): return list(map(int, input().split()))\n\n\ndef i_list(): return list(map(int, input().split()))\n\n\ndef i_row(N): return [int(input()) for _ in range(N)]\n\n\ndef i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]\ndef bit_search(n, list_n):\n\n    bit_ans=[]\n    for _ in range(2**n):\n        t = [0] * n\n        bit_ans.append(t)\n    for i in range(2 ** n):\n        for j in range(n):\n            if ((i >> j) & 1):\n                bit_ans[i][j] = list_n[j]\n\n    return bit_ans\n\ncost=10**18\nn,m,x= i_map()\ncaa=i_row_list(n)\nls=list(range(1,n+1))\nbls=bit_search(n,ls)\nfor bb in bls:\n    ch=[0]*(m+1)\n    for i in range(n):\n        if bb[i]!=0:\n            ch= [ c + b for (c,b) in zip(ch, caa[bb[i]-1])]\n    for i in range(m+1):\n        if i==0:\n            flg=1\n            tmp=ch[i]\n        else:\n            if ch[i]<x:\n                flg=0\n    if flg==1:\n        cost=min(cost,tmp)\nif cost==10**18:\n    cost=-1\nprint(cost)\n\n\n\n", "import numpy as np\nn,m,x = map(int, input().split())\ncosts = []\nunderstnding = []\nans = 10 ** 20\n\nfor _ in range(n):\n    tmp = list(map(int, input().split()))\n    costs.append(tmp[0])\n    understnding.append(tmp[1:])\n    \ncosts = np.array(costs)\nunderstnding = np.array(understnding)\n\nfor i in range(1, 2**n):\n    row = str(bin(i)).split(\"0b\")[1]\n    row = '0'*(n - len(row))+row\n    one_index = [j for j in range(len(row)) if row[j] ==\"1\"]\n    cost_sum = np.sum(costs[one_index])\n    under_sum = np.sum(understnding[one_index], axis=0)\n    if np.all(under_sum >= x) and cost_sum < ans:\n        ans = cost_sum\n    \nif ans == 10 ** 20:\n    print(-1)\nelse:\n    print(ans)", "from itertools import product\n[N, M, X] = [int(i) for i in input().split()]\nbk = [[int(i) for i in input().split()] for _ in range(N)]\n\nans = 12*10**5 + 1\nfor seq in product(range(2), repeat=N):\n    S = [0]*(M+1)\n    for i in range(N):\n       for j in range(M+1):\n           S[j] += seq[i]*bk[i][j]     \n    if min(S[1:M+1]) >= X:\n        ans = min(ans, S[0])\n\nif ans == 12*10**5 + 1:\n    print(-1)\nelse:\n    print(ans)", "from numpy import *\nN, M, X = map(int, input().split())\nB = [array(list(map(int, input().split())), uint32) for _ in range(N)]\nc = inf\nfor i in range(2**N):\n    a = zeros(M+1, uint32)\n    j = 0\n    while i:\n        if i&1: a += B[j]\n        i >>= 1\n        j += 1\n    C, *A = a\n    if min(A) >= X: c = min([c, C])\nprint(c if c<inf else-1)", "import numpy as np\n\nN, M, X = map(int, input().split())\nC = [list(map(int, input().split())) for _ in range(N)]\n\ncost = float(\"inf\")\nfor i in range(2**N):\n  tmp = np.array([0 for _ in range(M+1)])\n  for j in range(N):\n    if (i>>j) & 1:\n      tmp += np.array(C[j])\n  if min(tmp[1:]) >= X:\n    cost = min(cost, tmp[0])\n\nprint(-1 if cost == float(\"inf\") else cost)", "import numpy as np\nN,M,X=map(int,input().split())\nC=[[0 for i in range(M)] for j in range(N)]\nfor i in range(N):\n    C[i] = list(map(int, input().split()))\nD=np.array(C)\nE=[0]*2**N\n\nfor i in range(2**N):\n  c=format(i,'012b')\n  for j in range(N):\n    d=int(c[12-N+j])\n    E[i]+=D[j]*int(d)\n\nif min(E[-1][1:M+1])<X:\n  print(-1);return\n    \nMax=E[-1][0]+1\nMin=Max\nfor i in range(2**N):\n  if min(E[i][1:M+1])>=X:\n    if Min>E[i][0]:Min=E[i][0]\n    continue\n  else:E[i][0]=Max\nprint(Min)\nreturn", "import itertools as it\n\nN, M, X = map(int, input().split())\nbook = [[int(_) for _ in input().split()] for i in range(N)]\n\ncombs = it.product([0, 1], repeat=N)\nprices = []\nfor comb in combs:\n    # print(comb)\n    bag = [0] * (M+1)\n    for i in range(N):\n        if comb[i] == 0:\n            continue\n        else:\n            for j in range(M+1):\n                bag[j] += book[i][j]\n\n    if min(bag[1:]) < X:\n        continue\n    else:\n        prices.append(bag[0])\n\nif len(prices) == 0:\n    print(-1)\nelse:\n    print(min(prices))", "import itertools\nN,M,X = map(int,input().split())\nlsC = []\nlsM = []\nfor i in range(N):\n    ls = list(map(int,input().split()))\n    C = ls.pop(0)\n    lsC.append(C)\n    lsM.append(ls)\nlsP = itertools.product(range(2),repeat=N)\nans = 10**15\nfor i in lsP:\n    Call = 0\n    lsAll = [0]*M\n    f = True\n    for j in range(N):\n        if i[j] == 1:\n            Call += lsC[j]\n            for k in range(M):\n                lsAll[k] += lsM[j][k]\n    for l in range(M):\n        if lsAll[l] < X:\n            f = False\n            break\n    if f:\n        ans = min(ans,Call)\nif ans == 10**15:\n    print(-1)\nelse:\n    print(ans)", "n,m,x = list(map(int,input().split()))\n\narray = [list(map(int,input().split())) for _ in range(n)]\n\n# print(array)\n# print(n)\nans = 10 ** 8\nfor i in range(2**n):\n\n    skill = [0] * m\n    price = 0\n    count = 0\n    for k in range(n):\n        if (i >> k) & 1:\n\n            price += array[k][0]\n            for j in range(m):\n                skill[j] += array[k][j+1]\n    for l in range(m):\n        if skill[l] < x:\n            break\n        else:\n            count += 1\n    if count == m:\n        ans = min(ans, price)\n\nif ans == 10**8:\n    print((-1))\nelse:\n    print(ans)\n\n\n\n", "def __starting_point():\n\n    n,m,a = list(map(int,input().split()))\n\n    A = []\n    for i in range(n):\n        cmd = list(map(int,input().split()))\n        A.append(cmd)\n    #bit\u5168\u63a2\u7d22 \u8cb7\u3046\u30fb\u8cb7\u308f\u306a\u3044\u3092\u5224\u65ad\u3059\u308b\n    INF = 10**19\n    ans = INF\n    for x in range(2**n):\n        ALG = [0]*m\n        gokei = 0\n        for y in range(n):\n            if (x>>y) & 1:\n                #\u53d6\u5f97\u3059\u308b\u914d\u5217\u304c\u6c7a\u307e\u3063\u305f\u3089\u3001\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u7406\u89e3\u5ea6\u3092\uff0b\u3057\u3066\u3044\u304f\n                for j in range(m):\n                    ALG[j] += A[y][j+1]\n                gokei += A[y][0]\n        #Alg\u914d\u5217\u306e\u4e2d\u8eab\u304c\u3059\u3079\u3066\u7406\u89e3\u5ea6x\u3092\u8d85\u3048\u3066\u3044\u308b\u304b\u306e\u30c1\u30a7\u30c3\u30af\n        algflg=True\n        for k in ALG:\n            if k < a:\n                algflg=False\n                break\n        if algflg:\n            ans = min(ans,gokei)\n    if ans == INF:\n        print(\"-1\")\n    else:\n        print(ans)\n\n__starting_point()", "import sys\nfrom collections import deque, defaultdict, Counter\nfrom itertools import accumulate, product, permutations, combinations\nfrom operator import itemgetter\nfrom bisect import bisect_left, bisect_right\nfrom heapq import heappop, heappush\nfrom math import ceil, floor, sqrt, gcd, inf\nfrom copy import deepcopy\nimport numpy as np\nimport scipy as sp\n\nINF = inf\nMOD = 1000000007\n\nn, m, x = [int(i) for i in input().split()]\nA = [[int(i) for i in input().split()]for j in range(n)]    # n\u306f\u884c\u6570\n\ntmp = 0\nres = inf\n\nfor i in range(2 ** n):\n    s = f\"{i:0{n}b}\"\n    tmp = [0 for i in range(m + 1)]\n    for j in range(n):\n        if s[j] == \"1\":\n            for k in range(m + 1):\n                tmp[k] += A[j][k]\n    flg = True\n    for k in range(1, m + 1):\n        if tmp[k] < x:\n            flg = False\n    if flg:\n        res = min(res, tmp[0])\nif res == inf:\n    res = -1\n\nprint(res)\n", "import numpy as np\nN,M,X = map(int,input().split())\nC = []\nA = [[0]*M for i in range(N)]\nfor i in range(N):\n  temp = list(map(int,input().split()))\n  C.append(temp[0])\n  A[i]=temp[1:]\n#print(A)\nglobal_sum = 100000000\nalgorithm =  np.array([0]*M)\n\ndef check(alg,X):\n  flag = 1\n  for i in range(len(alg)):\n    if alg[i] < X:\n      flag=0\n  if flag ==1:\n    return True\n  else:\n    return False\nflag_2 = 0 \ndef calc(local_sum,alg,number,X):\n  nonlocal global_sum \n  nonlocal flag_2\n  #print(local_sum,alg,number)\n  if check(alg,X):\n    flag_2 = 1\n    if global_sum > local_sum:\n      global_sum = local_sum\n    return local_sum\n  elif number<N:\n    ## \u8cb7\u308f\u306a\u3044\n    alg = alg\n    calc(local_sum,alg,number+1,X)\n    ## \u8cb7\u3046\n    alg = alg + A[number]\n    calc(local_sum+C[number],alg,number+1,X)\n  else:\n    return\ncalc(0,algorithm,0,X)\nif flag_2 == 0 :\n  global_sum=-1\nprint(global_sum)", "N, M, X = map(int, input().split())\n\nC = []\nA = []\n\nfor _ in range(N):\n    q = list(map(int, input().split()))\n\n    C.append(q[0])\n    A.append(q[1:])\n\n#bit\u5168\u63a2\u7d22\n\nans = 1300000\n\nfor bit in range(1 << N):\n    acquire = [0] * M\n    cost = 0\n    for i in range(N):\n        if (bit >> i) % 2 == 1:\n            cost += C[i]\n            acquire = [a + b for a, b in zip(acquire, A[i])]\n\n    if min(acquire) >= X:\n        ans = min(ans, cost)\n\nif ans == 1300000:\n    ans = -1\n\nprint(ans)", "from itertools import combinations\n\nN, M, X = map(int, input().split())\nC, A = [], []\nfor i in range(N):\n    c, *a = map(int, input().split())\n    C.append(c)\n    A.append(a)\n\nans = float('INF')\nfor i in range(1,N+1):\n    for li in combinations(list(range(N)), i):\n        cost = 0\n        skill = [0] * M\n        for j in li:\n            cost += C[j]\n            for k in range(M):\n                skill[k] += A[j][k]\n        if all([s >= X for s in skill]):\n            ans = min(ans, cost)\nif ans == float('INF'):\n    print(-1)\nelse:\n    print(ans)", "n, m, x = list(map(int, input().split()))\ninp=[]\n\n# \u5165\u529b\u3092\u3059\u3079\u3066\u53d7\u3051\u53d6\u308b\nfor i in range(n):\n  tmp = list(map(int, input().split()))\n  inp.append(tmp)\n\n# bit\u5168\u63a2\u7d22\u3092\u884c\u3046\u305f\u3081\u306e\u7bb1\u3065\u304f\u308a\nsum = 0\nmin = 10**10\nfor i in range(2**n):\n  tmp = [0]*m\n  flg = 0\n  \n  # \u3042\u308b\u8cb7\u3046\u8cb7\u308f\u306a\u3044\u306e\u30b1\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u3001\u30d5\u30e9\u30b0\u304c\u7acb\u3063\u3066\u305f\u3089\u30b9\u30ad\u30eb\u30dd\u30a4\u30f3\u30c8\u3092\u5897\u3084\u3059\n  for j in range(n):\n    if ((i >> j) & 1):  # \u9806\u306b\u53f3\u306b\u30b7\u30d5\u30c8\u3055\u305b\u6700\u4e0b\u4f4dbit\u306e\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046\n      sum += inp[j][0]\n      for k in range(1,m+1):\n        #print(n,j, k, tmp, inp)\n        tmp[k-1] += inp[j][k]\n  for ii, k in enumerate(tmp):\n    if k < x: # x\u672a\u6e80\u306a\u3089flg\u3092\u305f\u3066\u3066NG\u3068\u3059\u308b\n      flg = 1\n      break\n  #print(tmp, flg)\n  if sum < min and flg == 0: min = sum\n  sum = 0\n  \nif min == 10**10: min = -1\nprint(min)\n", "import itertools as it\n\nN,M,X=list(map(int,input().split()))\nbook = [[int(_) for _ in input().split()] for i in range(N)]\n\ncombs = it.product([0, 1], repeat=N)\nprices = []\nfor comb in combs:\n\tbag = [0] * (M+1)\n\tfor i in range(N):\n\t\tif comb[i] == 0:\n\t\t\tcontinue\n\t\telse:\n\t\t\tfor j in range(M+1):\n\t\t\t\tbag[j]+=book[i][j]\n\tif min(bag[1:]) < X:\n\t\tcontinue\n\telse:\n\t\tprices.append(bag[0])\n\nif len(prices) == 0:\n\tprint((-1))\nelse:\n\tprint((min(prices)))\n", "N, M, X = map(int, input().split())\nitem = []\nans = []\nfor i in range(N):\n  item.append(list(map(int, input().split())))\nfor i in range(2**N):\n  bag = []\n  money = 0\n  for j in range(N):\n    if ((i>>j) & 1):\n      bag.append(item[j])\n  if bag == []:\n    continue\n  total = [0] * M\n  for k in bag:\n    money += k[0]\n    for l in range(1, M+1):\n      total[l-1] += k[l]\n  if min(total) >= X:\n    ans.append(money)\nif ans == []:\n  print(-1)\nelse:\n  print(min(ans))", "n,m,x = list(map(int,input().split()))\nca = [list(map(int,input().split())) for _ in range(n)]\n\nc = []\na = []\n\nfor i in range(n):\n    c.append(ca[i][0])\n    a.append(ca[i][1:])\n\nINF = 10**9\nans = INF\n\nfor i in range(1 << n):\n    sum_cost = 0\n    skill = [0]*m\n    for j in range(n):\n        if (i >> j)&1:\n            sum_cost += c[j]\n            for k in range(m):\n                skill[k] += a[j][k]\n    check_cnt = 0\n    for l in range(m):\n        if skill[l] >= x:\n            check_cnt += 1\n    if check_cnt == m:\n        ans = min(ans,sum_cost)\n\nif ans == INF:\n    print((-1))\nelse:\n    print(ans)\n", "N,M,X=list(map(int,input().split()))\n\nli=[]\nans=100000000000000000000000000000000\n\nfor j in range(N):\n    a=list(map(int,input().split()))\n    li.append(a)\n\nfor k in range(2**N):\n    temp=0\n    skill=[0]*M\n    k=str(bin(k))\n    k=k[2:]\n    while len(k)!=N:\n        k=\"0\"+k\n    for l in range(N):\n        if k[l]==\"1\":\n            temp+=li[l][0]\n            for m in range(1,M+1):\n                skill[m-1]+=li[l][m]\n    if min(skill)>=X:\n        if ans>temp:\n            ans=temp\nif ans==100000000000000000000000000000000:\n    print((-1))\nelse:\n    print(ans)\n", "N,M,X = map(int,input().split())\narray = [ list(map(int,input().split())) for _ in range(N) ]\nans = 10**18\nfor i in range ( 2**N ):\n  price = 0\n  skill = [0]*M\n  count = 0\n  for k in range(N):\n    if ( i >> k ) & 1:\n      price += array[k][0]\n      for j in range (M):\n        skill[j] += array[k][j+1]\n  for t in range(M):\n    if skill[t] < X:\n      break\n    else:\n      count += 1\n    if count == M:\n      ans = min(price,ans)\n      \nprint( -1 if ans == 10**18 else ans)", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nINF = 10000000000000\nN,M,X = map(int,input().split())\n\nC = []\nA = []\nfor i in range(N):\n    vec = list(map(int,input().split()))\n    C.append(vec[0])\n    A.append(vec[1:])\n\nans = INF\n\nfor bit in range(1 << N):\n    sum = 0\n    skill = [0] * M\n    for n in range(N):\n        if bit & (1 << n):\n            for i, s in enumerate(A[n],0):\n                skill[i] += s\n            sum += C[n]\n\n    flag = True\n    for i in range(M):\n        if skill[i] < X:\n            flag = False\n            break\n    if flag:\n        ans = min(ans,sum)\n\nif ans == INF:\n    print(-1)\nelse:\n    print(ans)", "import numpy as np\n\nN,M,X = map(int, input().split())\nbooks = []\nfor i in range(N):\n  tmp_book = list(map(int, input().split()))\n  books.append(tmp_book)\n\nans = 10**10\nfor i in range(1,2**(N)):\n  flag = 1\n  tmp = str(bin(i))\n  if len(tmp[2:]) < N:\n    tmp = '0'*(N-len(tmp[2:])) + tmp[2:]\n  else:\n    tmp = tmp[2:]\n  ability = np.zeros(M)\n  money = 0\n  for j in range(N):\n    if tmp[j] == '1':\n      ability += books[j][1:]\n      money += books[j][0]\n  #print(ability)\n  for j in range(M):\n    if ability[j] < X:\n      flag = 0\n      break\n  if flag == 1:\n    ans = min(ans, money)\nif ans == 10**10:\n  print(-1)\nelse:\n  print(ans)", "# -*- coding: utf-8 -*-\n\nN,M,X = map(int, input().split())\nCA = [list(map(int, input().split())) for _ in range(N)]\n\nans = -1\nfor i in range(1<<N):\n    bit = [0] * N\n    for j in range(N):\n        div = 1 << j\n        bit[j] = (i // div) % 2\n\n    res = [0] * M\n    cost = 0\n    for n in range(N):\n        if bit[n]==0:\n            continue\n        cost += CA[n][0]\n        for m in range(1,M+1):\n            res[m-1] += CA[n][m]\n\n    flag = True\n    for m in range(M):\n        if res[m] < X:\n            flag = False\n            break\n    \n    if flag:\n        if ans == -1:\n            ans = cost\n        else:\n            ans = min(ans, cost)\n\nprint(ans)", "import itertools as it\nN, M, X = list(map(int, input().split()))\nbook = [[int(_) for _ in input().split()] for i in range(N)]\n# print(f'book={book}')\ncombs = it.product([0, 1], repeat=N)\nprices = []\nfor comb in combs:\n    # print(comb)\n    bag = [0] * (M + 1)\n    for i in range(N):\n        if comb[i] == 0:\n            continue\n        else:\n            for j in range(M + 1):\n                bag[j] += book[i][j]\n    # print(f'bag={bag}')\n    if min(bag[1:]) < X:\n        continue\n    else:\n        prices.append(bag[0])\nif len(prices) == 0:\n    print((-1))\nelse:\n    print((min(prices)))\n", "from copy import deepcopy\n\nN, M, X = [int(i) for i in input().split()]\n\nCAS = [[int(i) for i in input().split()] for _ in range(N)]\n\n\nok = False\nmi = [float('inf'), *[0]*(M)]\n\nfs = '{:0' + str(N) + 'b}'\n\nfor i in range(2**N):\n  s = fs.format(i)\n  t = [0]*(M+1)\n  for i, f in enumerate(s):\n    if f == '1':\n      t = [a+b for a, b in zip(CAS[i], t)]\n\n  if all(a >= X for a in t[1:]) and mi[0] > t[0]:\n    mi = t\n    ok = True\n\n\nif ok:\n  print((mi[0]))\nelse:\n  print((-1))\n", "n,m,x = map(int,input().split())\nc = [list(map(int,input().split())) for _ in range(n)]\nans = []\n#n\u518a\u306e\u672c\u306b\u304a\u3044\u3066\u8cb7\u3046\u304b\u8cb7\u308f\u306a\u3044\u304b\u306e2\u901a\u308a\u306a\u306e\u30672**n\nfor i in range(2**n):\n    #\u30ea\u30b9\u30c8\u306e\u4e2d\u8eab\u306f\u5024\u6bb51\u3068\u7406\u89e3\u5ea6m\u500b\n    a = [0]*m\n    price = 0\n    for j in range(n):\n        #n\u518a\u3042\u308b\u3046\u3061j\u518a\u76ee\u3092\u8cb7\u3046\u304b\u8cb7\u308f\u306a\u3044\u304b\u3092\u5224\u5b9a\n        if ((i >> j) & 1):\n            for k in range(m):\n                a[k] += c[j][k+1]\n            #j\u518a\u3081\u3092\u8cb7\u3046\u306e\u3067\u3001\u5408\u8a08\u91d1\u984d\u3092\u5897\u3084\u3059\n            price += c[j][0]\n    if all(j >= x for j in a):\n        ans.append(price)\n\nif len(ans) == 0:\n    print(\"-1\")\nelse:\n    print(min(ans))", "n, m, x = list(map(int, input().split()))\nll = [list(map(int, input().split())) for _ in range(n)]\nans = 10**9\n\nfor i in range(2**n):\n    a = [0]*m\n    cnt = 0\n    for j in range(n):\n        if i>>j & 1:\n            for k in range(1, m+1):\n                a[k-1] += ll[j][k]\n            cnt += ll[j][0]\n    if all(s >= x for s in a):\n        ans = min(ans, cnt)\nprint((ans if ans < 10**9 else -1))\n", "import numpy as np\nimport itertools\n\ndef check():\n    N,M,X = map(int, input().split())\n    A = np.array([[int(i) for i in input().split()] for _ in range(N)])\n    total = np.sum(A,axis=0)\n    flag = True if all((a>=X  for a in total[1:])) else False\n    ans = total[0]\n\n    if flag:\n        for i in range(1,N+1):\n            for v in itertools.combinations([i for i in range(N)], i):\n                B = np.array([A[j] for j in v])\n                total2 = np.sum(B, axis=0)\n                sabun = total-total2\n                if all(a>=X for a in sabun[1:]):\n                    ans = min(ans, sabun[0])\n    print(ans if flag else -1)\n    \ncheck()", "import itertools\nimport numpy as np\nimport copy\n\nN, M, X = list(map(int, input().split()))\nCA = [list(map(int, input().split())) for _ in range(N)]\nCA = np.array(CA)\n\nans = 10 ** 7\nfor i in itertools.product([0, 1], repeat=N):\n    tCA = copy.copy(CA)\n    for j in range(N):\n        if i[j] == 0:\n            tCA[j] = np.zeros(CA.shape[1])\n    s = np.sum(tCA, axis=0)\n    l = sum(k >= X for k in s[1:])\n    if s[0] < ans and l == M:\n        ans = s[0]\n\nif ans == 10 ** 7:\n    print((-1))\nelse:\n    print(ans)\n", "n,m,x = list(map(int,input().split()))\nca = [list(map(int,input().split())) for _ in range(n)]\n\nc = []\na = []\nfor i in range(n):\n    c.append(ca[i][0])\n    a.append(ca[i][1:])\n\nINF = 10**9\nans = INF\nfor i in range(1<<n):\n    skill = [0]*m\n    sum_cost = 0\n    for j in range(n):\n        if (i >> j)&1:\n            for k in range(m):\n                skill[k] += a[j][k]\n            sum_cost += c[j]\n    if min(skill) >= x:\n        ans = min(ans,sum_cost)\n\nif ans == INF:\n    print((-1))\nelse:\n    print(ans)\n", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\n#import numpy as np\nfrom itertools import product\ndef main():\n    n, m, x = list(map(int, input().split()))\n    books = []\n    for _ in range(n):\n        books.append(tuple(map(int, input().split())))\n    p = tuple(product((0, 1), repeat=n))\n    r = float('inf')\n    for pe in p:\n        effects = [0] * (m + 1)\n        for i1 in range(n):\n            if pe[i1]:\n                for i2 in range(m+1):\n                    effects[i2] += books[i1][i2]\n        if all([e >= x for e in effects[1:]]):\n            r = min(r, effects[0])\n    if r == float('inf'):\n        print((-1))\n    else:\n        print(r)\n\ndef __starting_point():\n    main()\n\n__starting_point()", "#\n# abc167 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9\"\"\"\n        output = \"\"\"120\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5\"\"\"\n        output = \"\"\"-1\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_3(self):\n        input = \"\"\"8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2\"\"\"\n        output = \"\"\"1067\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N, M, X = list(map(int, input().split()))\n    CA = [list(map(int, input().split())) for _ in range(N)]\n\n    ans = float(\"inf\")\n    for bit in range(1 << N):\n        S = [0]*(M+1)\n        for i, ca in enumerate(CA):\n            if (1 << i) & bit == 1 << i:\n                S = list(map(sum, list(zip(S, ca))))\n        for s in S[1:]:\n            if s < X:\n                break\n        else:\n            ans = min(ans, S[0])\n\n    if ans == float(\"inf\"):\n        ans = -1\n\n    print(ans)\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "from copy import deepcopy\n\nN, M, X = [int(i) for i in input().split()]\n\nCAS = [[int(i) for i in input().split()] for _ in range(N)]\n\n\nok = False\nmi = [float('inf'), *[0]*(M)]\n\nfor i in range(2**N):\n  t = [0]*(M+1)\n  for j in range(N):\n    if (i >> j) & 1:\n      t = [a+b for a, b in zip(CAS[j], t)]\n\n  if all(a >= X for a in t[1:]) and mi[0] > t[0]:\n    mi = t\n    ok = True\n\n\nif ok:\n  print((mi[0]))\nelse:\n  print((-1))\n", "import sys\nN, M, X = map(int, input().split())\nC = [0 for _ in range(N)]\nA = [[0 for _ in range(M)] for _ in range(N)]\nfor i in range(N):\n    S = list(map(int, input().split()))\n    C[i] = S[0]\n    for j in range(1,M+1):\n        A[i][j-1] = S[j]\n \nans = 10**9\nfor i in range(2**N):\n    hantei = 0\n    tmp = 0\n    score = [0]*M\n    for n in range(N):\n        if (i >> n) & 1 == 1:\n            tmp += C[n]\n            for j in range(M):\n                score[j] += A[n][j]\n\n    for j in range(M):\n        if score[j]>=X: hantei += 1 \n    if hantei == M:\n        ans = min(ans, tmp) \n    if i == 2**N -1 and hantei != M:\n        print(-1)\n        return      \n    \nprint(ans)", "\ndef main():\n    n, m, x = map(int, input().split(\" \"))\n    ca =[]\n    a = []\n    c = []\n    INF = 1e7\n    ans = INF\n    for i in range(n):\n        ca.append(list(map(int, input().split(\" \"))))\n    for i in range(n):\n        c.append(ca[i][0])\n        a.append(ca[i][1:])\n    for i in range(1<<n):\n        a_sum = [0]*m\n        c_sum = 0\n        for j in range(n):\n            if i >> j & 1 == 1:\n                for k in range(m):\n                    a_sum[k] += a[j][k]\n                c_sum += c[j]\n        if min(a_sum) >= x and c_sum < ans:\n            ans = c_sum\n    if ans == INF:\n        print(-1)\n    else:\n        print(ans)\n        \n\ndef __starting_point():\n    main()\n__starting_point()", "# author:  Taichicchi\n# created: 14.09.2020 22:23:14\n\nimport sys\nfrom itertools import combinations\n\nN, M, X = list(map(int, input().split()))\n\nC = []\nA = []\n\nfor i in range(N):\n    c, *a = list(map(int, input().split()))\n    C.append(c)\n    A.append(a)\ncomb = [0, 1, 2]\n\nsave = []\n\nfor choice in range(1, N + 1):\n    for comb in combinations(list(range(N)), choice):\n        ls = [0 for _ in range(M)]\n        for i in comb:\n            for m in range(M):\n                ls[m] += A[i][m]\n            if all(list([x >= X for x in ls])):\n                save.append(sum([C[_] for _ in comb]))\nif save:\n    print((min(save)))\nelse:\n    print((-1))\n", "n,m,x=[int(i) for i in input().split()]\nc=[]\narr=[[] for i in range(n)]\nfor i in range(n):\n    l=[int(i) for i in input().split()]\n    c.append(l[0])\n    arr[i]=l[1:]\n\ninf=10**18\nans=inf\n\nlimit=2**n\nfor bit in range(1,limit):\n    sum=[0 for i in range(m)]\n    cost=0\n    for i in range(n):\n        if (1<<i & bit):\n            cost+=c[i]\n            for j in range(m):\n                sum[j]+=arr[i][j]\n    flag=1\n    for i in range(m):\n        if sum[i]<x:\n            flag=0\n            break\n    if flag==0:\n        continue\n    ans=min(ans,cost)\nif ans!=inf:\n    print(ans)\nelse:\n    print((-1))\n", "n,m,x=list(map(int,input().split()))\nl=[list(map(int,input().split(\" \"))) for i in range(n)]\nans=[]\nfor i in range(1<<n):\n    cond = [0]*n\n    for j in range(n):\n        if 1&(i>>j):\n            cond[j] = 1\n    count=[0]*(m+1)\n    for k in range(n):\n        if cond[k]==1:\n            for s in range(m+1):\n                count[s]+=l[k][s]\n    flag=0\n    for a in range(1,m+1):\n        if count[a]<x:\n            flag=1\n            break\n    if flag==0:\n        ans.append(count[0])\nif ans==[]:\n    print((-1))\nelse:\n    print((min(ans)))\n            \n", "N, M, X = list(map(int, input().split()))\na = []\nfor i in range(N):\n    a.append(list(map(int, input().split())))\n\nd = []\n\nfor i in range(1 << N):\n    s = [0] * M\n    c = 0\n    for j in range(N):\n        if (i >> j) & 1:\n            # print(j, \"entry\")\n            for k in range(M):\n                s[k] += a[j][k+1]\n            c += a[j][0]\n\n    # print(s, c, d)\n\n    b = True\n    for ii in s:\n        if ii < X:\n            b = False\n    if b:\n        d.append(c)\n\nif len(d) == 0:\n    print(\"-1\")\nelse:\n    print((min(d)))\n\n\n", "[N, M, X] = list(map(int, list(input().split(' '))))\nA = []\nC = []\nfor i in range(N):\n    c, *a = list(map(int, input().split(' ')))\n    C.append(c)\n    A.append(a)\n#print(C)\n#print(A)\n\nINF = 10**10\nmin_cost = INF\n\nfor b in range(2**N): \n    # \u3053\u308c\u304c\u30d0\u30a4\u30ca\u30ea\u30fc\u30d9\u30fc\u30b9\u306e\u5168\u63a2\u7d22\u3068\u306a\u308b\u3002\u4eca\u56de\u306e\u30ad\u30e2 part 1\n    # \u4e00\u3064\u306e\u30eb\u30fc\u30d7\u304c\u672c\u306e\u8cfc\u5165\u30bb\u30c3\u30c8\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u308b\n    # \u5404\u30d3\u30c3\u30c8\u304c\u305d\u308c\u305e\u308c\u306e\u672c\u3092\u8cfc\u5165\u3059\u308b\u304b\u3069\u3046\u304b\u8868\u3057\u3066\u3044\u308b\n    # \u56e0\u307f\u306b b \u306f bit \u3092\u8868\u3057\u3066\u3044\u308b\u3064\u3082\u308a\n    cost = 0 # \u3053\u306e\u8cfc\u5165\u30bb\u30c3\u30c8\u3067\u4f7f\u3046\u91d1\u984d\n    algo_level = [0] * M # \u5404\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u30c8\u30d4\u30c3\u30af\u306e\u7406\u89e3\u5ea6\n    for i in range(N): \n        # \u3053\u308c\u304c\u5404\u672c\u306e\u30b3\u30b9\u30c8\u3068\u7406\u89e3\u5ea6\u53d6\u5f97\u306e\u305f\u3081\u306e\u30eb\u30fc\u30d7\n        # i \u756a\u76ee\u306e\u672c\u306b\u5bfe\u3057\u3066\u30eb\u30fc\u30d7\u3092\u56de\u3057\u3066\u3044\u304f\n        if(b >> i & 1): # \u3053\u306e\u884c\u304c\u4eca\u56de\u306e\u30ad\u30e2 part 2\u3002\n            # i \u756a\u76ee\u306e\u672c\u306e\u8cfc\u5165\u6709\u7121\u3092\u5224\u5b9a\u3059\u308b\u305f\u3081\u306b\u3001\u30d3\u30c3\u30c8\u30b7\u30d5\u30c8\u3057\u305f\u5024\u306b\u5bfe\u3057\u3066 '1 = 0b1' (\u3064\u307e\u308a\u5358\u306a\u308b (2\u9032\u6570\u306e) 1) \u3068\u306e\u8ad6\u7406\u7a4d\u3092\u6c42\u3081\u3066\u3044\u308b\n            # \u3053\u306e if \u6587\u304c True \u3067\u3042\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3001i \u756a\u76ee\u306e\u672c\u3092\u8cb7\u3063\u305f\u3068\u3044\u3046\u3053\u3068\n            cost += C[i]\n            for a in range(M): # (\u5404\u672c\u306b\u3042\u308b) \u5404\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u306b\u5bfe\u3059\u308b\u30eb\u30fc\u30d7\n                algo_level[a] += A[i][a]\n    if(min(algo_level) >= X): # \u5168\u3066\u306e\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u30c8\u30d4\u30c3\u30af\u304c X \u4ee5\u4e0a\u306e\u7406\u89e3\u5ea6\u3067\u3042\u308b\u5834\u5408\u2026\n        min_cost = min(cost, min_cost)\n\nif(min_cost < INF):\n    print(min_cost)\nelse:\n    print('-1')\n\n\n\n\n", "from itertools import combinations\n\ndef solve():\n  N, M, X = map(int, input().split())\n  C = []\n  A = []\n  for _ in range(N):\n    c, *A_ = list(map(int, input().split()))\n    C.append(c)\n    A.append(A_)\n    # print(C, list(A_))\n\n  ret = 10**9\n  for m in range(1, N+1):\n    for comb in combinations(range(N), m):\n      vec = [0]*M\n      cost = 0\n      for i in comb:\n        for j,A_e in enumerate(A[i]):\n          vec[j] += A_e\n        cost += C[i]\n\n      # print(comb, vec)\n      if min(vec) >= X:\n        ret = min(ret, cost)\n\n  print(ret if ret < 10**9 else -1)\n  \nsolve()"]


Question:
An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. However, moving 5 positions at once is very tiring, and the elephant needs to take a nap after doing so. Determine, what is the minimum number of steps he need to make in order to get to his friend's house.

-----Input-----

The first line of the input contains an integer x (1 ≤ x ≤ 1 000 000) — The coordinate of the friend's house.

-----Output-----

Print the minimum number of steps that elephant needs to make to get from point 0 to point x.

-----Examples-----
Input
5

Output
1

Input
12

Output
3

-----Note-----

In the first sample the elephant needs to make one step of length 5 to reach the point x.

In the second sample the elephant can get to point x if he moves by 3, 5 and 4. There are other ways to get the optimal answer but the elephant cannot reach x in less than three moves.

["from math import ceil\nn = int(input())\nprint(ceil(n/5))\n", "x = int(input())\nans = (x - 1) // 5 + 1\nprint(ans)\n", "n = int(input())\nprint((n - 1) // 5 + 1)\n", "dp = [0] * 1000005\nx = int(input())\ndp[0] = 0\ndp[1] = 1\ndp[2] = 1\ndp[3] = 1\ndp[4] = 1\ndp[5] = 1\nfor i in range(6, 1000001):\n    dp[i] = min([dp[i-1], dp[i-2], dp[i-3], dp[i-4], dp[i-5]])+1\nprint(dp[x])\n", "x = int(input())\nans = 0\nans += x // 5\nif x % 5 != 0:\n    ans += 1\nprint(ans)", "n = int(input())\ncur = 0\nans = 0\nwhile (n - cur) > 5:\n    cur += 5\n    ans += 1\nprint(ans + 1)", "a = int(input())\nprint((a+4)//5)\n", "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2016 missingdays <missingdays@missingdays>\n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\n\n\"\"\"\n\na = int(input())\n\nb = a // 5\n\nc = a % 5\n\nif c > 0:\n    print(b+1)\nelse:\n    print(b)\n", "x = int(input())\nprint(x//5 + (x%5 != 0))\n", "n = int(input())\nprint(n//5 + (1 if n%5 > 0 else 0))\n", "x = int(input())\nret = x//5\nif x%5 != 0:\n\tret += 1\nprint (ret)", "a=int(input())\nif a%5==0:\n    print(a//5)\nelse:\n    print(a//5+1)", "n = int(input())\n\nans = 0\n\nans += n // 5\nn = n % 5\nans += n // 4\nn = n % 4\nans += n // 3\nn = n % 3\nans += n // 2\nn = n % 2\nans += n // 1\nn = n % 1\n\nprint(ans)", "x = int(input())\nprint(x//5 + min(x%5, 1))\n", "x = int(input())\np = x//5\nif x%5 != 0:\n    p += 1\n\nprint(p)", "import math\nprint(math.ceil(int(input()) / 5))\n", "n = int(input())\nans = 0\nfor i in range(5, 0, -1):\n    ans += (n // i)\n    n -= (n // i * i)\nprint(ans)    \n", "n = int(input())\nprint((n + 4) // 5)", "3\nimport math\n\nx = int(input())\n\nprint(str(math.ceil(x/5)))\n", "n = int(input())\nans = n // 5\nif n % 5 != 0:\n    ans += 1\nprint(ans)", "x = int(input())\nif x%5==0:\n\tprint(x//5)\nelse:\n\tprint(x//5 +1)", "#author=\"_rabbit\"\nn=int(input())\nans=int(n/5)\nif(n%5):\n    ans+=1\nprint(ans)\n", "n = int(input())\n\nprint(n // 5 + (((n % 5) + 4)//5))\n"]


Question:
You are a lover of bacteria. You want to raise some bacteria in a box.

Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. Also, each night after splitting, exactly two bacteria will mutate into a different strain. You hope to see exactly x bacteria in the box at some moment.

What is the minimum number of bacteria you need to put into the box across those days?

-----Input-----

The only line containing one integer x (1 ≤ x ≤ 10^9).

-----Output-----

The only line containing one integer: the answer.

-----Examples-----
Input
5

Output
2

Input
8

Output
1

-----Note-----

For the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.

For the second sample, we can put one in the first morning and in the 4-th morning there will be 8 in the box. So the answer is 1.

["n = int(input())\nans = 1\n\nwhile n != 1:\n    if  n % 2 == 1:\n        ans += 1\n        n -= 1\n    else:\n        n //= 2\n\nprint(ans)", "x = int(input())\nprint(bin(x).count('1'))\n", "n = int(input())\na = 0\nwhile (n > 0):\n    a += n % 2\n    n //= 2\nprint(a)", "x = int(input())\n\nans = 0\nwhile x > 0:\n    ans += x % 2\n    x //= 2\nprint(ans)\n", "n = int(input())\nprint(str(bin(n)).count('1'))", "def f(n):\n    if n == 0:\n        return 0\n    if n % 2 == 1:\n        return f(n // 2) + 1\n    else:\n        return f(n // 2)\n    \n    \nn = int(input())\nprint(f(n))", "n = int(input())\nc = 0\nwhile n > 0:\n\tc += n % 2\n\tn //= 2\n\nprint(c)\n", "n = int(input())\n#a = [int(c) for c in input().split()]\ncount = 0\n\nwhile n > 0:\n    if n & 1 == 1:\n        count += 1\n    n = n >> 1\nprint(count)\n", "import sys\n\nlines = sys.stdin.read().split(\"\\n\")\n# n, k = map(int, lines[0].split(\" \"))\n# n = int(lines[0])\n# nums = list(map(int, lines[1].split(\" \")))\n\nn = int(lines[0])\nprint(sum(map(int, bin(n)[2:])))\n", "print(bin(int(input())).count('1'))", "n = int(input())\ns = bin(n)[2:]\nprint(sum(list(map(int, s))))", "n = int(input())\nans = 0\nwhile n > 0:\n    ans += n%2\n    n //= 2\nprint(ans)", "print(bin(int(input())).count('1'))\n", "a = int(input())\ns = bin(a)\nk = 0;\nfor i in range(len(s)):\n\tif (s[i] == '1'):\n\t\tk += 1\nprint(k)", "print(str(bin(int(input()))).count('1'))", "n = int(input())\ns = bin(n)\nans=0\nn = len(s)\nfor i in range(n-1,1,-1):\n    if s[i] == '1':\n        ans+=1\nprint(ans)", "a = int(input())\nans = 0\nwhile(a != 0):\n\tj = 0\n\twhile(a % 2 == 0):\n\t\tj = 1\n\t\ta //= 2\n\tif (j == 0):\n\t\tans += 1\n\t\ta -= 1\nprint(ans)", "n = int(input())\nans = 0\nwhile (n!=0):\n    if n%2==1:\n        n-=1\n        ans +=1\n    else:\n        n//=2\nprint(ans)\n", "a=int(input())\nans=0\nwhile a != 0:\n    c=a%2\n    ans=ans+c\n    a=a//2\nprint(ans)\n", "def main():\n    mode=\"filee\"\n    if mode==\"file\":f=open(\"test.txt\",\"r\")\n\n    if mode==\"file\":n=int(f.readline())\n    else:n=int(input())\n    print(sum( (n>>shift)&1 for shift in range(128) ))\n\n\n    if mode==\"file\":f.close()\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "import math\nwithFile = 0\n\nif(withFile == 1):\n    fin     = open('input.txt', 'r')\n    fout    = open('output.txt', 'w')\n\ndef getl():\n    if(withFile == 0):\n        return input()\n    else:\n        return fin.readline()\ndef printl(s):\n    if(withFile == 0):\n        print(s)\n    else:\n        fout.write(str(s))\ndef get_arr():\n    x = getl().split(' ')\n    if(x[-1] == ''):\n        x = x[:-1]\n    return list(map(int, x))\n\ndef f(x):\n    if(x == 0):\n        return 0\n    d = 1\n    while(d < x):\n        d <<= 1\n    if(d != x):\n        d >>= 1\n    return 1 + f(x - d)\n\nx = get_arr()[0]\n\nprint(f(x))\n\n\n\nif(withFile == 1):\n    fin.close()\n    fout.close()", "n = int(input())\ncol = 0\nwhile n > 0:\n    q = 0\n    while 2 ** (q + 1) <= n:\n        q += 1\n    n -= 2 ** q\n    col += 1\nprint(col)\n        \n", "n = int(input())\nprint(str(bin(n)).count(\"1\"))\n", "#import sys\n#sys.stdin = open(\"python/in\", \"r\")\n#from collections import defaultdict\n#import numpy as np\n#import array as rr\n#arr = rr.array('q')\n\nn = int(input())\n#n, m = [int (i) for i in input().split(\" \")]\nans = 0\nwhile n > 0:\n    if n%2 == 1:\n        ans += 1\n    n = n//2\n\nprint(ans)", "a = int(input())\nif a == 1:\n\tprint(1)\nelse:\n\tans = 1\n\twhile a != 1:\n\t\tif a % 2:\n\t\t\tans += 1\n\t\t\ta -= 1\n\t\ta /= 2\n\tprint(ans)"]


Question:
Dilku and Bhopu live in Artland. Dilku loves Bhopu and he writes a message : “iloveyou”
on paper and wishes to send it to Bhopu. As Dilku is busy making an artwork, he asks his friend Raj to send the message to Bhopu. However Raj has a condition that he may add/remove some  characters and jumble the letters of the message.
As Bhopu understands Dilku, she can read “iloveyou” from the message if all the characters of the string “iloveyou” are in the message received by her. Bhopu is happy if she can read “iloveyou” from the message. Otherwise, she is sad. Raj is happy if S contains at least two identical letters; otherwise, he is sad. Tell whether Bhopu is happy or sad.

-----Input-----
Input contains a string S, where S is the message received by Bhopu. String S consists of only lowercase letters.

-----Output-----
Output “happy” if Bhopu is happy and “sad” if Bhopu is sad.

-----Constraints-----
1 ≤ |S| ≤ 100
Where |S| denotes length of message string S

-----Example-----
Input 1:
iloveyou

Output 1:
happy

Input 2:
ulrvysioqjifo

Output 2:
sad

Input 3:
abcvleouioydef

Output 3:
happy

["#!/usr/bin/python\na = input()\nx='iloveyou'\nfor i in x:\n if i not in a:\n  print(\"sad\")\n  return\nif a.count('o') < 2:\n print(\"sad\")\n return\nprint(\"happy\")\nreturn", "t=\"iloveyou\"\np=1\ns=input()\nfor i in t:\n if i not in s:\n  p=0\n  break\n\n\n\nif p is 1 :\n print(\"happy\")\nelse:\n print('sad')", "a = str(input())\ni = 0\nl = 0\no = 0\nv = 0\ne = 0\ny = 0\nu = 0\nfor i in range(len(a)):\n if a[i]=='i':\n  i+=1\n elif a[i]=='l':\n  l+=1\n elif a[i]=='o':\n  o+=1\n elif a[i]=='v':\n  v+=1\n elif a[i]=='e':\n  e+=1\n elif a[i]=='y':\n  y+=1\n elif a[i]=='u':\n  u+=1\nif i>=1 and l>=1 and o>=2 and v>=1 and e>=1 and y>=1 and u>=1:\n print('happy')\nelse:\n print('sad')"]

{"inputs": [["iloveyou"], ["ulrvysioqjifo"], ["abcvleouioydef"]], "outputs": [["happy"], ["sad"], ["happy"]]}


Question:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.
After finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.
Important note: in the European Union, dates are written in dd/mm/yyyy format instead.

-----Constraints-----
 - S is a string of length 10.
 - The first eight characters in S are 2017/01/.
 - The last two characters in S are digits and represent an integer between 1 and 31 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
Replace the first four characters in S with 2018 and print it.

-----Sample Input-----
2017/01/07

-----Sample Output-----
2018/01/07