output_description: If T satisfies the property in Problem Statement, print `Yes`; otherwise,
  print `No`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
      T
attempt: #!/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]
              if min_cost < cost:
                  break
              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()
  
problem_description: Statement
  
  Takahashi wants to be a member of some web service.
  
  He tried to register himself with the ID S, which turned out to be already
  used by another user.
  
  Thus, he decides to register using a string obtained by appending one
  character at the end of S as his ID.
  
  He is now trying to register with the ID T. Determine whether this string
  satisfies the property above.
samples: [{"input": "chokudai\n    chokudaiz", "output": "Yes\n    \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n    snekee", "output": "No\n    \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n    aa", "output": "Yes"}]