using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 3 10");
            WillReturn.Add("60 2 2 4");
            WillReturn.Add("70 8 7 9");
            WillReturn.Add("50 2 3 9");
            //120
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3 3 10");
            WillReturn.Add("100 3 1 4");
            WillReturn.Add("100 1 5 9");
            WillReturn.Add("100 2 6 5");
            //-1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("8 5 22");
            WillReturn.Add("100 3 7 5 3 1");
            WillReturn.Add("164 4 5 2 7 8");
            WillReturn.Add("334 7 2 7 2 9");
            WillReturn.Add("234 4 7 2 8 2");
            WillReturn.Add("541 5 4 3 3 6");
            WillReturn.Add("235 4 8 6 9 7");
            WillReturn.Add("394 3 6 1 6 2");
            WillReturn.Add("872 8 4 3 7 2");
            //1067
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct JyoutaiDef
    {
        internal int CurrInd;
        internal int SumCost;
        internal int[] AArr;
    }

    struct BookInfoDef
    {
        internal int Cost;
        internal int[] AArr;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray();

        SplitAct(InputList[0]);
        int UB = wkArr[1] - 1;
        int X = wkArr[2];

        var BookInfoList = new List<BookInfoDef>();
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);

            BookInfoDef WillAdd;
            WillAdd.Cost = wkArr[0];
            WillAdd.AArr = wkArr.Skip(1).ToArray();
            BookInfoList.Add(WillAdd);
        }

        var Stk = new Stack<JyoutaiDef>();
        JyoutaiDef WillPush;
        WillPush.CurrInd = 0;
        WillPush.SumCost = 0;
        WillPush.AArr = new int[UB + 1];
        Stk.Push(WillPush);

        int Answer = int.MaxValue;
        bool HasAnswer = false;
        while (Stk.Count > 0) {
            JyoutaiDef Popped = Stk.Pop();

            // 全てのアルゴリズムの理解度がX以上の場合
            if (Array.TrueForAll(Popped.AArr, pX => pX >= X)) {
                if (Popped.SumCost < Answer) {
                    Answer = Popped.SumCost;
                    HasAnswer = true;
                }
                continue;
            }

            for (int I = Popped.CurrInd; I <= BookInfoList.Count - 1; I++) {
                WillPush.CurrInd = I + 1;
                WillPush.SumCost = Popped.SumCost + BookInfoList[I].Cost;
                WillPush.AArr = (int[])Popped.AArr.Clone();

                for (int J = 0; J <= UB; J++) {
                    WillPush.AArr[J] += BookInfoList[I].AArr[J];
                }
                Stk.Push(WillPush);
            }
        }
        if (HasAnswer) {
            Console.WriteLine(Answer);
        }
        else {
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 28700