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

void main()
{
    long n, m;
    readf("%d %d\n", &n, &m);

    long[] as = [];
    long[] cs = [];

    foreach (i; 0 .. m)
    {
        long a, b;
        readf("%d %d\n", &a, &b);
        as ~= a;
        cs ~= readln.strip
            .split
            .to!(long[])
            .map!(c => 1 << (c - 1))
            .reduce!((a, b) => a | b);
    }

    const target = (1 << n) - 1;
    auto dp = new long[](1 << n);
    const inf = long.max / 4;
    foreach (ref d; dp)
    {
        d = inf;
    }
    dp[0] = 0;
    foreach (i; 0 .. m)
    {
        foreach (j; 0 .. (1 << n))
        {
            dp[j | cs[i]] = min(dp[j | cs[i]], dp[j] + as[i]);
        }
    }

    if (dp[target] == inf)
    {
        writeln(-1);
    }
    else
    {
        writeln(dp[target]);
    }

}
