n,m=map(int,input().split())
INF=10**9
dp=[INF for i in range(2**n)]
dp[0]=0
for i in range(m):
    a,b=map(int,input().split())
    tmp=0
    for j in list(map(int,input().split())):
        tmp+=2**(j-1)
    dp[tmp]=min(dp[tmp],a)
for i in range(2**n):
    for j in range(2**n):
        dp[i|j]=min(dp[i]+dp[j],dp[i|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 INF=10**9 INF 10**9 10 9 INF for i in range(2**n) for i in range(2**n) i range(2**n) range 2**n 2 n for i in range(2**n) INF dp=[INF for i in range(2**n)] dp [INF for i in range(2**n)] dp[0]=0 dp[0] dp 0 0 for i in range(m):
    a,b=map(int,input().split())
    tmp=0
    for j in list(map(int,input().split())):
        tmp+=2**(j-1)
    dp[tmp]=min(dp[tmp],a) i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b tmp=0 tmp 0 for j in list(map(int,input().split())):
        tmp+=2**(j-1)
     j list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split tmp+=2**(j-1) tmp 2**(j-1) 2 j-1 j 1 dp[tmp]=min(dp[tmp],a) dp[tmp] dp tmp min(dp[tmp],a) min dp[tmp] dp tmp a for i in range(2**n):
    for j in range(2**n):
        dp[i|j]=min(dp[i]+dp[j],dp[i|j]) i range(2**n) range 2**n 2 n for j in range(2**n):
        dp[i|j]=min(dp[i]+dp[j],dp[i|j]) j range(2**n) range 2**n 2 n dp[i|j]=min(dp[i]+dp[j],dp[i|j]) dp[i|j] dp i|j i j min(dp[i]+dp[j],dp[i|j]) min dp[i]+dp[j] dp[i] dp i dp[j] dp j dp[i|j] dp i|j i 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 b=map(int,input().split()) map(int,input().split()) b dp=[INF for i in range(2**n)] [INF for i in range(2**n)] dp a,b=map(int,input().split()) map(int,input().split()) a tmp+=2**(j-1) 2**(j-1) tmp m=map(int,input().split()) map(int,input().split()) m tmp=0 0 tmp n,m=map(int,input().split()) map(int,input().split()) n INF=10**9 10**9 INF
n,m=map(int,input().split())
INF=10**9
dp=[INF for i in range(2**n)]
dp[0]=0
for i in range(m):
    a,b=map(int,input().split())
    tmp=0
    for j in list(map(int,input().split())):
        tmp+=2**(j-1)
    dp[tmp]=min(dp[tmp],a)
for i in range(2**n):
    for j in range(2**n):
        dp[i|j]=min(dp[i]+dp[j],dp[i|j])
if dp[-1]==INF:
    print(-1)
else:
    print(dp[-1])