n,m = map(int, input().split())
a=[]
c=[]
for i in range(m):
    tmp,_=map(int, input().split())
    a.append(tmp)
    tmp=list(map(int, input().split()))
    bit = 0
    for b in tmp:
        bit+=(1<<(b-1))
    c.append(bit)

dp = [[10**9 for i in range(2**n)] for j in range(m+1)]
dp[0][0]=0

for i in range(m):
    cst = a[i]
    key=c[i]
    for s in range(2**n):
        dp[i+1][s] = min(dp[i+1][s], dp[i][s])
        dp[i+1][s|key] = min(dp[i+1][s|key], dp[i][s]+cst)

ans=dp[-1][-1]
if ans ==10**9:
    print(-1)
else:
    print(ans) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a=[] a [] c=[] c [] for i in range(m):
    tmp,_=map(int, input().split())
    a.append(tmp)
    tmp=list(map(int, input().split()))
    bit = 0
    for b in tmp:
        bit+=(1<<(b-1))
    c.append(bit) i range(m) range m tmp,_=map(int, input().split()) tmp map(int, input().split()) map int input().split() ().split () input split _ a.append(tmp) a.append a append tmp tmp=list(map(int, input().split())) tmp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bit = 0 bit 0 for b in tmp:
        bit+=(1<<(b-1))
     b tmp bit+=(1<<(b-1)) bit 1<<(b-1) 1 b-1 b 1 c.append(bit) c.append c append bit [10**9 for i in range(2**n)] for j in range(m+1) for j in range(m+1) j range(m+1) range m+1 m 1 for j in range(m+1) [10**9 for i in range(2**n)] dp = [[10**9 for i in range(2**n)] for j in range(m+1)] dp [[10**9 for i in range(2**n)] for j in range(m+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    cst = a[i]
    key=c[i]
    for s in range(2**n):
        dp[i+1][s] = min(dp[i+1][s], dp[i][s])
        dp[i+1][s|key] = min(dp[i+1][s|key], dp[i][s]+cst) i range(m) range m cst = a[i] cst a[i] a i key=c[i] key c[i] c i for s in range(2**n):
        dp[i+1][s] = min(dp[i+1][s], dp[i][s])
        dp[i+1][s|key] = min(dp[i+1][s|key], dp[i][s]+cst) s range(2**n) range 2**n 2 n dp[i+1][s] = min(dp[i+1][s], dp[i][s]) dp[i+1][s] [i+1] dp i+1 i 1 s min(dp[i+1][s], dp[i][s]) min dp[i+1][s] [i+1] dp i+1 i 1 s dp[i][s] [i] dp i s dp[i+1][s|key] = min(dp[i+1][s|key], dp[i][s]+cst) dp[i+1][s|key] [i+1] dp i+1 i 1 s|key s key min(dp[i+1][s|key], dp[i][s]+cst) min dp[i+1][s|key] [i+1] dp i+1 i 1 s|key s key dp[i][s]+cst dp[i][s] [i] dp i s cst ans=dp[-1][-1] ans dp[-1][-1] [-1] dp -1 -1 if ans ==10**9:
    print(-1)
else:
    print(ans) ans ==10**9 ans 10**9 10 9 print(-1) print -1 print(ans) print ans _=map(int, input().split()) map(int, input().split()) _ bit+=(1<<(b-1)) 1<<(b-1) bit ans=dp[-1][-1] dp[-1][-1] ans n,m = map(int, input().split()) map(int, input().split()) n tmp=list(map(int, input().split())) list(map(int, input().split())) tmp cst = a[i] a[i] cst dp = [[10**9 for i in range(2**n)] for j in range(m+1)] [[10**9 for i in range(2**n)] for j in range(m+1)] dp key=c[i] c[i] key bit = 0 0 bit a=[] [] a tmp,_=map(int, input().split()) map(int, input().split()) tmp m = map(int, input().split()) map(int, input().split()) m c=[] [] c
n,m = map(int, input().split())
a=[]
c=[]
for i in range(m):
    tmp,_=map(int, input().split())
    a.append(tmp)
    tmp=list(map(int, input().split()))
    bit = 0
    for b in tmp:
        bit+=(1<<(b-1))
    c.append(bit)

dp = [[10**9 for i in range(2**n)] for j in range(m+1)]
dp[0][0]=0

for i in range(m):
    cst = a[i]
    key=c[i]
    for s in range(2**n):
        dp[i+1][s] = min(dp[i+1][s], dp[i][s])
        dp[i+1][s|key] = min(dp[i+1][s|key], dp[i][s]+cst)

ans=dp[-1][-1]
if ans ==10**9:
    print(-1)
else:
    print(ans)