void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], m = tmp[1];

    long[] dp = new long[](1<<n);
    dp[1..$] = 1L << 60;
    foreach (i; 0 .. m)
    {
        tmp = readln.split.to!(long[]);
        long a = tmp[0], b = tmp[1];
        long[] c = readln.split.to!(long[]);

        long pos;
        foreach (x; c)
        {
            pos |= 1 << (x - 1);
        }

        foreach (j; 0 .. 1<<n)
        {
            dp[j|pos] = min(dp[j|pos], dp[j]+a);
        }
    }

    writeln(dp[$-1] != 1L << 60 ? dp[$-1] : -1);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;