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

long[long] dp;

long dfs(in long[] as, in long[] cs, long i, long cur_money, long cur_boxes, long target)
{
    if (i >= as.length)
    {
        return long.max - 1;
    }
    if (cur_boxes == target)
    {
        return cur_money;
    }
    if (cur_boxes in dp)
    {
        return dp[cur_boxes];
    }

    long a = dfs(as, cs, i + 1, cur_money, cur_boxes, target);
    if ((cs[i] | cur_boxes) != cur_boxes)
    {
        long b = dfs(as, cs, i + 1, cur_money + as[i], cur_boxes | cs[i], target);
        a = min(a, b);
    }
    dp[cur_boxes] = a;
    return dp[cur_boxes];
}

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;
    long res = dfs(as, cs, 0, 0, 0, target);
    if (res == long.max - 1)
    {
        writeln(-1);
    }
    else
    {
        writeln(res);
    }

}
