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

alias Key = Tuple!(int, "cost", int, "mask");

int calc(int num, Key[] keys) {
    int n = cast(int)keys.length;
    auto dp = new int[][](n, 1 << num);
    for (int i = 0; i < dp.length; i++) dp[i][] = int.max;

    dp[0][keys[0].mask] = keys[0].cost;
    for (int i = 1; i < n; i++) {
        int cost = keys[i].cost;
        int mask = keys[i].mask;
        dp[i][mask] = cost;
        for (int j = 0; j < (1 << num); j++) {
            if (dp[i-1][j] == int.max) continue;
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            dp[i][j | mask] = min(dp[i][j | mask], dp[i-1][j] + cost);
        }
    }
    int ans = dp[n-1][(1 << num) - 1];
    return ans == int.max ? -1 : ans;
}

void main() {
    int n, m; scan(n, m);
    Key[] keys;
    foreach (_; 0..m) {
        int a, b; scan(a, b);
        auto c = readints;
        int mask = 0;
        foreach (e; c) mask |= (1 << (e-1));
        keys ~= Key(a, mask);
    }
    writeln(calc(n, keys));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
