import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto keys = new ulong[](M);
    auto value = new long[](M);
    ulong sum;
    foreach (i; 0 .. M)
    {
        long a, b;
        scan(a, b);
        value[i] = a;
        auto C = aryread();
        foreach (c; C)
            keys[i] |= (1 << (c - 1));
        sum |= keys[i];
    }
    if (sum != (1 << N) - 1)
    {
        writeln(-1);
        return;
    }
    auto dp = new long[][](M + 1, 2 ^^ N);
    // dp[i][j] == i番目まで鍵を選んで状態jに到達する最小コスト
    foreach (i; 0 .. M + 1)
        dp[i][] = long.max;
    dp[0][0] = 0;
    foreach (i; 0 .. M)
        foreach (j; 0 .. (1 << N))
            if (dp[i][j] != long.max)
            {
                // writefln("%d %010b %d", i, j, dp[i][j]);
                dp[i + 1][j] = dp[i + 1][j].min(dp[i][j]);
                dp[i + 1][j | keys[i]] = dp[i + 1][j | keys[i]].min(dp[i][j] + value[i]);
            }
    writeln(dp[M][(1 << N) - 1]);
}
