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");

long calc(int num, Key[] keys) {
    int n = cast(int)keys.length;

    // dp[i 番目の鍵][宝箱の鍵(ビットマスク)]
    auto dp = new long[][](n + 1, 1 << num);
    for (int i = 0; i < dp.length; i++) dp[i][] = int.max;

    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        int cost = keys[i].cost;
        int mask = keys[i].mask;
        for (int j = 0; j < (1 << num); j++) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j | mask] = min(dp[i+1][j | mask], dp[i][j] + cost);
        }
    }
    auto ans = dp[n][(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;
