n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1]) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a_list = [] a_list [] c = [] c [] for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split())))) i range(m) range m a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b a_list.append(a) a_list.append a_list append a c.append(sum(1 << j-1 for j in list(map(int,input().split())))) c.append c append sum(1 << j-1 for j in list(map(int,input().split()))) sum 1 << j-1 1 j-1 j 1 inf = 10**10 inf 10**10 10 10 dp = [inf]*(1 << n) dp [inf]*(1 << n) [inf] inf 1 << n 1 n dp[0] = 0 dp[0] dp 0 0 for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j]) i range(1 << n) range 1 << n 1 n for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j]) j range(m) range m dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j]) dp[c[j]|i] dp c[j]|i c[j] c j i min(dp[c[j]|i],dp[i]+a_list[j]) min dp[c[j]|i] dp c[j]|i c[j] c j i dp[i]+a_list[j] dp[i] dp i a_list[j] a_list j if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1]) dp[-1] == inf dp[-1] dp -1 inf print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 a_list = [] [] a_list n,m = map(int,input().split()) map(int,input().split()) n c = [] [] c m = map(int,input().split()) map(int,input().split()) m inf = 10**10 10**10 inf dp = [inf]*(1 << n) [inf]*(1 << n) dp a,b = map(int,input().split()) map(int,input().split()) a b = map(int,input().split()) map(int,input().split()) b
n,m = map(int,input().split())
a_list = []
c = []

for i in range(m):
    a,b = map(int,input().split())
    a_list.append(a)
    c.append(sum(1 << j-1 for j in list(map(int,input().split()))))

inf = 10**10
dp = [inf]*(1 << n)
dp[0] = 0

for i in range(1 << n):
    for j in range(m):
        dp[c[j]|i] = min(dp[c[j]|i],dp[i]+a_list[j])

if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])