from heapq import heappush, heappop

from collections import deque,defaultdict,Counter

import itertools

from itertools import permutations,combinations

import sys

import bisect

import string

#import math

#import time

import random

def I():

    return int(input())

def MI():

    return map(int,input().split())

def LI():

    return [int(i) for i in input().split()]

def LI_():

    return [int(i)-1 for i in input().split()]

def StoI():

    return [ord(i)-97 for i in input()]

def show(*inp,end='\n'):

    if show_flg:

        print(*inp,end=end)

YN=['Yes','No']

mo=10**9+7

#ts=time.time()

sys.setrecursionlimit(10**6)

#input=sys.stdin.readline

show_flg=False

#show_flg=True



n,m=MI()

t=1<<n

key=[]

for i in range(m):

    a,b=MI()

    c=0

    for j in LI_():

        c+=1<<j

    key.append((a,c))

inf=float('inf')

dp=[[inf]*(m+1) for _ in range(t)]

#dp[stat][m] # min value using up to m and open stat

dp[0][0]=0



for j in range(1,m+1):

    for i in range(t):

        cost,ck=key[j-1]

        show(i,j,'|',dp[ck|i][j],min(dp[ck|i][j-1],dp[i][j-1]+cost))

        dp[ck|i][j]=min(dp[ck|i][j],dp[ck|i][j-1],dp[i][j-1]+cost)

        dp[i][j]=min(dp[i][j],dp[i][j-1])

        

for i in dp:

    show(*i)



ans=dp[t-1][m] if dp[t-1][m]!=inf else -1

print(ans)

from subprocess import*

with open('e.cpp','w')as f:f.write(r"""

#include <bits/stdc++.h>

using namespace std;



const int maxs = 4096;

int dp[maxs];



int main() {

	memset(dp, 0x3f, 16384);

	dp[0] = 0;

	int n, m;

	cin >> n >> m;

	while (m--) {

		int a, b, s = 0;

		cin >> a >> b;

		while (b--) {

			int c;

			cin >> c;

			s ^= 1 << c - 1;

		}

		dp[s] = min(dp[s], a);

	}

	for (int i = 0; i != n; ++i) for (int all = (1 << n) - 1 ^ 1 << i, sub = all; sub; sub = sub - 1 & all)

		dp[sub] = min(dp[sub], dp[sub ^ 1 << i]);

	for (int s = 0; s != (1 << n); ++s) if (s != (s & -s))

		for (int t = s - 1 & s; t != s; t = t - 1 & s)

			dp[s] = min(dp[s], dp[t] + dp[s ^ t]);

	int mask = (1 << n) - 1;

	if (dp[mask] == 0x3f3f3f3f) dp[mask] = -1;

	cout << dp[mask] << endl;

}""")

call(('g++','e.cpp'))

call('./a.out')

from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string

# import math
# import time
import random


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return [int(i) for i in input().split()]


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def show(*inp, end="\n"):
    if show_flg:
        print(*inp, end=end)


YN = ["Yes", "No"]
mo = 10**9 + 7
# ts=time.time()
sys.setrecursionlimit(10**6)
# input=sys.stdin.readline
show_flg = False
# show_flg=True
n, m = MI()
t = 1 << n
key = []
for i in range(m):
    a, b = MI()
    c = 0
    for j in LI_():
        c += 1 << j
    key.append((a, c))
inf = float("inf")
dp = [[inf] * (m + 1) for _ in range(t)]
# dp[stat][m] # min value using up to m and open stat
dp[0][0] = 0
for j in range(1, m + 1):
    for i in range(t):
        cost, ck = key[j - 1]
        show(i, j, "|", dp[ck | i][j], min(dp[ck | i][j - 1], dp[i][j - 1] + cost))
        dp[ck | i][j] = min(dp[ck | i][j], dp[ck | i][j - 1], dp[i][j - 1] + cost)
        dp[i][j] = min(dp[i][j], dp[i][j - 1])
for i in dp:
    show(*i)
ans = dp[t - 1][m] if dp[t - 1][m] != inf else -1
print(ans)

from subprocess import *

with open("e.cpp", "w") as f:
    f.write(
        r"""
#include <bits/stdc++.h>
using namespace std;
const int maxs = 4096;
int dp[maxs];
int main() {
	memset(dp, 0x3f, 16384);
	dp[0] = 0;
	int n, m;
	cin >> n >> m;
	while (m--) {
		int a, b, s = 0;
		cin >> a >> b;
		while (b--) {
			int c;
			cin >> c;
			s ^= 1 << c - 1;
		}
		dp[s] = min(dp[s], a);
	}
	for (int i = 0; i != n; ++i) for (int all = (1 << n) - 1 ^ 1 << i, sub = all; sub; sub = sub - 1 & all)
		dp[sub] = min(dp[sub], dp[sub ^ 1 << i]);
	for (int s = 0; s != (1 << n); ++s) if (s != (s & -s))
		for (int t = s - 1 & s; t != s; t = t - 1 & s)
			dp[s] = min(dp[s], dp[t] + dp[s ^ t]);
	int mask = (1 << n) - 1;
	if (dp[mask] == 0x3f3f3f3f) dp[mask] = -1;
	cout << dp[mask] << endl;
}"""
    )
call(("g++", "e.cpp"))
call("./a.out")

-from heapq import heappush, heappop -from collections import deque, defaultdict, Counter -import itertools -from itertools import permutations, combinations -import sys -import bisect -import string +from subprocess import * -# import math -# import time -import random - - -def I(): -    return int(input()) - - -def MI(): -    return map(int, input().split()) - - -def LI(): -    return [int(i) for i in input().split()] - - -def LI_(): -    return [int(i) - 1 for i in input().split()] - - -def StoI(): -    return [ord(i) - 97 for i in input()] - - -def show(*inp, end="\n"): -    if show_flg: -        print(*inp, end=end) - - -YN = ["Yes", "No"] -mo = 10**9 + 7 -# ts=time.time() -sys.setrecursionlimit(10**6) -# input=sys.stdin.readline -show_flg = False -# show_flg=True -n, m = MI() -t = 1 << n -key = [] -for i in range(m): -    a, b = MI() -    c = 0 -    for j in LI_(): -        c += 1 << j -    key.append((a, c)) -inf = float("inf") -dp = [[inf] * (m + 1) for _ in range(t)] -# dp[stat][m] # min value using up to m and open stat -dp[0][0] = 0 -for j in range(1, m + 1): -    for i in range(t): -        cost, ck = key[j - 1] -        show(i, j, "|", dp[ck | i][j], min(dp[ck | i][j - 1], dp[i][j - 1] + cost)) -        dp[ck | i][j] = min(dp[ck | i][j], dp[ck | i][j - 1], dp[i][j - 1] + cost) -        dp[i][j] = min(dp[i][j], dp[i][j - 1]) -for i in dp: -    show(*i) -ans = dp[t - 1][m] if dp[t - 1][m] != inf else -1 -print(ans) +with open("e.cpp", "w") as f: +    f.write( +        r""" +#include <bits/stdc++.h> +using namespace std; +const int maxs = 4096; +int dp[maxs]; +int main() { +	memset(dp, 0x3f, 16384); +	dp[0] = 0; +	int n, m; +	cin >> n >> m; +	while (m--) { +		int a, b, s = 0; +		cin >> a >> b; +		while (b--) { +			int c; +			cin >> c; +			s ^= 1 << c - 1; +		} +		dp[s] = min(dp[s], a); +	} +	for (int i = 0; i != n; ++i) for (int all = (1 << n) - 1 ^ 1 << i, sub = all; sub; sub = sub - 1 & all) +		dp[sub] = min(dp[sub], dp[sub ^ 1 << i]); +	for (int s = 0; s != (1 << n); ++s) if (s != (s & -s)) +		for (int t = s - 1 & s; t != s; t = t - 1 & s) +			dp[s] = min(dp[s], dp[t] + dp[s ^ t]); +	int mask = (1 << n) - 1; +	if (dp[mask] == 0x3f3f3f3f) dp[mask] = -1; +	cout << dp[mask] << endl; +}""" +    ) +call(("g++", "e.cpp")) +call("./a.out")