import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
lis = []
for i in range(m):
    tmp = list(map(int,input().split()))
    tmp.extend(list(map(int,input().split())))
    lis.append(tmp)

dp = [[1000000000 for i in range(2**n)]for i in range(m+1)]
dp[0][0]=0
for i in range(m):
    clis = 0
    for j in lis[i][2:]:
        clis += 2**(j-1)

    for sin in range(2**n):
        #print(dp[i][sin]+lis[i][0],clis|sin)
        dp[i+1][clis|sin] = min(dp[i][sin]+lis[i][0],dp[i+1][clis|sin])
    for sin in range(2**n):
        dp[i+1][sin] = min(dp[i+1][sin],dp[i][sin])

#print(lis)
#print(*dp,sep="\n")
if dp[m][-1]==1000000000:
    print(-1)
else:
    print(dp[m][-1]) import sys sys def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m lis = [] lis [] for i in range(m):
    tmp = list(map(int,input().split()))
    tmp.extend(list(map(int,input().split())))
    lis.append(tmp) i range(m) range m tmp = list(map(int,input().split())) tmp list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split tmp.extend(list(map(int,input().split()))) tmp.extend tmp extend list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split lis.append(tmp) lis.append lis append tmp [1000000000 for i in range(2**n)]for i in range(m+1) for i in range(m+1) i range(m+1) range m+1 m 1 for i in range(m+1) [1000000000 for i in range(2**n)] dp = [[1000000000 for i in range(2**n)]for i in range(m+1)] dp [[1000000000 for i in range(2**n)]for i in range(m+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    clis = 0
    for j in lis[i][2:]:
        clis += 2**(j-1)

    for sin in range(2**n):
        #print(dp[i][sin]+lis[i][0],clis|sin)
        dp[i+1][clis|sin] = min(dp[i][sin]+lis[i][0],dp[i+1][clis|sin])
    for sin in range(2**n):
        dp[i+1][sin] = min(dp[i+1][sin],dp[i][sin])

#print(lis)
#print(*dp,sep="\n") i range(m) range m clis = 0 clis 0 for j in lis[i][2:]:
        clis += 2**(j-1)

     j lis[i][2:] [i] lis i 2: 2 clis += 2**(j-1) clis 2**(j-1) 2 j-1 j 1 for sin in range(2**n):
        #print(dp[i][sin]+lis[i][0],clis|sin)
        dp[i+1][clis|sin] = min(dp[i][sin]+lis[i][0],dp[i+1][clis|sin])
     sin range(2**n) range 2**n 2 n dp[i+1][clis|sin] = min(dp[i][sin]+lis[i][0],dp[i+1][clis|sin]) dp[i+1][clis|sin] [i+1] dp i+1 i 1 clis|sin clis sin min(dp[i][sin]+lis[i][0],dp[i+1][clis|sin]) min dp[i][sin]+lis[i][0] dp[i][sin] [i] dp i sin lis[i][0] [i] lis i 0 dp[i+1][clis|sin] [i+1] dp i+1 i 1 clis|sin clis sin for sin in range(2**n):
        dp[i+1][sin] = min(dp[i+1][sin],dp[i][sin])

#print(lis)
#print(*dp,sep="\n") sin range(2**n) range 2**n 2 n dp[i+1][sin] = min(dp[i+1][sin],dp[i][sin]) dp[i+1][sin] [i+1] dp i+1 i 1 sin min(dp[i+1][sin],dp[i][sin]) min dp[i+1][sin] [i+1] dp i+1 i 1 sin dp[i][sin] [i] dp i sin if dp[m][-1]==1000000000:
    print(-1)
else:
    print(dp[m][-1]) dp[m][-1]==1000000000 dp[m][-1] [m] dp m -1 1000000000 print(-1) print -1 print(dp[m][-1]) print dp[m][-1] [m] dp m -1 m=map(int,input().split()) map(int,input().split()) m clis = 0 0 clis dp = [[1000000000 for i in range(2**n)]for i in range(m+1)] [[1000000000 for i in range(2**n)]for i in range(m+1)] dp lis = [] [] lis tmp = list(map(int,input().split())) list(map(int,input().split())) tmp clis += 2**(j-1) 2**(j-1) clis def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input n,m=map(int,input().split()) map(int,input().split()) n
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
lis = []
for i in range(m):
    tmp = list(map(int,input().split()))
    tmp.extend(list(map(int,input().split())))
    lis.append(tmp)

dp = [[1000000000 for i in range(2**n)]for i in range(m+1)]
dp[0][0]=0
for i in range(m):
    clis = 0
    for j in lis[i][2:]:
        clis += 2**(j-1)

    for sin in range(2**n):
        #print(dp[i][sin]+lis[i][0],clis|sin)
        dp[i+1][clis|sin] = min(dp[i][sin]+lis[i][0],dp[i+1][clis|sin])
    for sin in range(2**n):
        dp[i+1][sin] = min(dp[i+1][sin],dp[i][sin])

#print(lis)
#print(*dp,sep="\n")
if dp[m][-1]==1000000000:
    print(-1)
else:
    print(dp[m][-1])
