from sys import stdin

import numpy as np



def main():

    readline = stdin.readline

    n, m, x = map(int, readline().split())

    a = [list(map(int, readline().split())) for _ in range(n)]

    res = []

    for i in range(2 ** n):

        price = 0

        skill = []



        for j in range(1 << n):

            if ((i >> j) & 1) == 1:

                price += a[j][0]

                skill.append(a[j][1:])

        np_skill = np.array(skill)

        skill_sum = np.sum(np_skill, axis=0)\

                        if np_skill.shape[0] > 1 else np_skill



        if skill_sum.size != 0 and (skill_sum >= x).all():

            res.append(price)



    if not res: return print('-1')



    return print(min(res))



if __name__ == '__main__':

    main()

from sys import stdin

import numpy as np



def bit_search(a, n, m, x):

    res = []

    for i in range(2 ** n):

        price = 0

        skill = np.zeros((n, m))

        for j in range(n):

            if (i >> j) & 1:

                price += a[j][0]

                skill[j] = a[j][1:]

        skill_sum = np.sum(skill, axis=0)\

                        if skill.shape[0] > 1 else skill

        if (skill_sum >= x).all(): res.append(price)

    return res



def main():

    readline = stdin.readline

    n, m, x = map(int, readline().split())

    a = [list(map(int, readline().split())) for _ in range(n)]

    res = bit_search(a, n, m, x)

    print('-1' if not res else min(res))

    return



if __name__ == '__main__':

    main()

from sys import stdin
import numpy as np


def main():
    readline = stdin.readline
    n, m, x = map(int, readline().split())
    a = [list(map(int, readline().split())) for _ in range(n)]
    res = []
    for i in range(2**n):
        price = 0
        skill = []
        for j in range(1 << n):
            if ((i >> j) & 1) == 1:
                price += a[j][0]
                skill.append(a[j][1:])
        np_skill = np.array(skill)
        skill_sum = np.sum(np_skill, axis=0) if np_skill.shape[0] > 1 else np_skill
        if skill_sum.size != 0 and (skill_sum >= x).all():
            res.append(price)
    if not res:
        return print("-1")
    return print(min(res))


if __name__ == "__main__":
    main()

from sys import stdin
import numpy as np


def bit_search(a, n, m, x):
    res = []
    for i in range(2**n):
        price = 0
        skill = np.zeros((n, m))
        for j in range(n):
            if (i >> j) & 1:
                price += a[j][0]
                skill[j] = a[j][1:]
        skill_sum = np.sum(skill, axis=0) if skill.shape[0] > 1 else skill
        if (skill_sum >= x).all():
            res.append(price)
    return res


def main():
    readline = stdin.readline
    n, m, x = map(int, readline().split())
    a = [list(map(int, readline().split())) for _ in range(n)]
    res = bit_search(a, n, m, x)
    print("-1" if not res else min(res))
    return


if __name__ == "__main__":
    main()

+ + +def bit_search(a, n, m, x): +    res = [] +    for i in range(2**n): +        price = 0 +        skill = np.zeros((n, m)) +        for j in range(n): +            if (i >> j) & 1: +                price += a[j][0] +                skill[j] = a[j][1:] +        skill_sum = np.sum(skill, axis=0) if skill.shape[0] > 1 else skill +        if (skill_sum >= x).all(): +            res.append(price) +    return res -    res = [] -    for i in range(2**n): -        price = 0 -        skill = [] -        for j in range(1 << n): -            if ((i >> j) & 1) == 1: -                price += a[j][0] -                skill.append(a[j][1:]) -        np_skill = np.array(skill) -        skill_sum = np.sum(np_skill, axis=0) if np_skill.shape[0] > 1 else np_skill -        if skill_sum.size != 0 and (skill_sum >= x).all(): -            res.append(price) -    if not res: -        return print("-1") -    return print(min(res)) +    res = bit_search(a, n, m, x) +    print("-1" if not res else min(res)) +    return