unittest
{
	assert( [ "2 3", "10 1", "1", "15 1", "2", "30 2", "1 2" ].solve == 25 );
	assert( [ "12 1", "100000 1", "2" ].solve == -1 );
	assert( [ "4 6", "67786 3", "1 3 4", "3497 1", "2", "44908 3", "2 3 4", "2156 3", "2 3 4", "26230 1", "2", "86918 1", "3" ].solve == 69942 );
}



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

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

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	auto as = new long[ m ];
	auto ss = new long[ m ];
	foreach( ref a, ref s; lockstep( as, ss ) )
	{
		input.popFront;
		a = input.front.split.to!( long[] )[ 0 ];
		input.popFront;
		foreach( c; input.front.split.to!( long[] ) )
		{
			s |= 1L << ( c - 1 );
		}
	}
	
	// dp[ 開けられる宝箱のbit集合 ] = 合計費用
	auto dp = new long[ 1L << n ];
	dp[ 1 .. $ ] = long.max;
	foreach( i; 0L .. dp.length.signed )
	{
		foreach( a, s; lockstep( as, ss ) )
		{
			if( dp[ i ] < long.max ) dp[ i | s ] = min( dp[ i | s ], dp[ i ] + a );
		}
	}
	return ( dp[ $ - 1 ] == long.max ) ? -1 : dp[ $ - 1 ];
}
