import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    struct key {
        int cost;
        int[] boxes;
    }
    
    auto unlockable = new bool[] (n);
    
    key[] keys;
    foreach (_; 0 .. m) {
        int a, b;
        readf("%s %s", &a, &b);
        readln;
        
        auto arr = readln.chomp.split.map!(to!int).array;
        
        arr = arr.map!(x => x-1).array;
        foreach (e; arr) { unlockable[e] = true; }
        
        keys ~= key(a, arr);
    }
    
    debug { keys.writeln; }
    
    if (!unlockable.all()) {
        writeln(-1);
        return;
    }
    
    immutable int INF = 10 ^^ 5 * 100;
    auto dp = new int[][] (m+1, 1 << n);
    foreach (i; 0 .. m+1) {
        dp[i][] = INF;
        dp[0][(1 << n) - 1] = 0;
    }
    
    int go(int mxm, int st) {
        debug { writeln(mxm, ' ', st); }
        
        if (dp[mxm][st] != INF) { return dp[mxm][st]; }
        
        debug { writeln(mxm, ' ', st); }
        
        int unlock(int cur, int[] nrs) {
            foreach (e; nrs) { cur |= (1 << e); }
            return cur;
        }
        
        foreach_reverse (i, e; keys[0 .. mxm]) {
            dp[mxm][st] = min(dp[mxm][st], go(i.to!int, unlock(st, e.boxes)) + e.cost);
        }
        
        return dp[mxm][st];
    }
    
    auto ans = go(m, 0);
    
    ans.writeln;
}