unittest
{
	assert( [ "3 3 10", "60 2 2 4", "70 8 7 9", "50 2 3 9" ].parse.expand.solve == 120 );
	assert( [ "3 3 10", "100 3 1 4", "100 1 5 9", "100 2 6 5" ].parse.expand.solve == -1 );
	assert( [ "8 5 22", "100 3 7 5 3 1", "164 4 5 2 7 8", "334 7 2 7 2 9", "234 4 7 2 8 2", "541 5 4 3 3 6", "235 4 8 6 9 7", "394 3 6 1 6 2", "872 8 4 3 7 2" ].parse.expand.solve == 1067 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmx = input.front.split.to!( long[] );
	auto cs = new long[ nmx[ 0 ] ];
	auto ass = new long[][]( nmx[ 0 ], nmx[ 1 ] );
	foreach( ref c, ref as; lockstep( cs, ass ) )
	{
		input.popFront;
		auto cas = input.front.split.to!( long[] );
		c = cas[ 0 ];
		as = cas[ 1 .. $ ];
	}
	return tuple( nmx[ 2 ], cs, ass );
}

auto solve( long x, long[] cs, long[][] ass )
{
	auto ans = long.max;
	foreach( b; 1L .. 1L << cs.length )
	{
		auto ct = 0L;
		auto ats = new long[ ass[ 0 ].length ];
		foreach( i, c; cs )
		{
			if( ( b & ( 1L << i ) ) == 0 ) continue;
			
			ct += c;
			ats[] += ass[ i ][];
		}
		if( ats.find!( ( a, b ) => a < b )( x ).empty ) ans = min( ans, ct );
	}
	return ( ans == long.max ) ? -1L : ans;
}
