# ABC142 E

f=lambda:map(int,input().split())
N,M=f()
INF=float('inf')

dp=[[INF]*(1<<N) for _ in [0]*(M+1)]
dp[0][0]=0
# dp[m][s]:=n個目まででsを開けるために必要な最小コスト
def list2int(A):
    res=0
    for a in A:
        res+=2**(a-1)
    return res
    
for m in range(M):
    a,b=f()
    c=list2int(list(f()))
    for i in range(1<<N):
        # 次のカギ買った
        dp[m+1][i|c]=min(dp[m][i]+a,dp[m+1][i|c])
        # やめといた
        dp[m+1][i]=min(dp[m][i],dp[m+1][i])
res=dp[M][(1<<N)-1]
print(res if res<INF else -1) f=lambda:map(int,input().split()) f lambda:map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split N,M=f() N f() f M INF=float('inf') INF float('inf') float 'inf' [INF]*(1<<N) for _ in [0]*(M+1) for _ in [0]*(M+1) _ [0]*(M+1) [0] 0 M+1 M 1 for _ in [0]*(M+1) [INF]*(1<<N) [INF] INF 1<<N 1 N dp=[[INF]*(1<<N) for _ in [0]*(M+1)] dp [[INF]*(1<<N) for _ in [0]*(M+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 def list2int(A):
    res=0
    for a in A:
        res+=2**(a-1)
    return res
     list2int res=0 res 0 for a in A:
        res+=2**(a-1)
     a A res+=2**(a-1) res 2**(a-1) 2 a-1 a 1 return res res A A for m in range(M):
    a,b=f()
    c=list2int(list(f()))
    for i in range(1<<N):
        # 次のカギ買った
        dp[m+1][i|c]=min(dp[m][i]+a,dp[m+1][i|c])
        # やめといた
        dp[m+1][i]=min(dp[m][i],dp[m+1][i]) m range(M) range M a,b=f() a f() f b c=list2int(list(f())) c list2int(list(f())) list2int list(f()) list f() f for i in range(1<<N):
        # 次のカギ買った
        dp[m+1][i|c]=min(dp[m][i]+a,dp[m+1][i|c])
        # やめといた
        dp[m+1][i]=min(dp[m][i],dp[m+1][i]) i range(1<<N) range 1<<N 1 N dp[m+1][i|c]=min(dp[m][i]+a,dp[m+1][i|c]) dp[m+1][i|c] [m+1] dp m+1 m 1 i|c i c min(dp[m][i]+a,dp[m+1][i|c]) min dp[m][i]+a dp[m][i] [m] dp m i a dp[m+1][i|c] [m+1] dp m+1 m 1 i|c i c dp[m+1][i]=min(dp[m][i],dp[m+1][i]) dp[m+1][i] [m+1] dp m+1 m 1 i min(dp[m][i],dp[m+1][i]) min dp[m][i] [m] dp m i dp[m+1][i] [m+1] dp m+1 m 1 i res=dp[M][(1<<N)-1] res dp[M][(1<<N)-1] [M] dp M (1<<N)-1 1<<N 1 N 1 print(res if res<INF else -1) print res if res<INF else -1 res<INF res INF res -1 f=lambda:map(int,input().split()) lambda:map(int,input().split()) f N,M=f() f() N def list2int(A):
    res=0
    for a in A:
        res+=2**(a-1)
    return res
     def list2int(A):
    res=0
    for a in A:
        res+=2**(a-1)
    return res
     list2int dp=[[INF]*(1<<N) for _ in [0]*(M+1)] [[INF]*(1<<N) for _ in [0]*(M+1)] dp INF=float('inf') float('inf') INF c=list2int(list(f())) list2int(list(f())) c res=dp[M][(1<<N)-1] dp[M][(1<<N)-1] res M=f() f() M a,b=f() f() a b=f() f() b
# ABC142 E

f=lambda:map(int,input().split())
N,M=f()
INF=float('inf')

dp=[[INF]*(1<<N) for _ in [0]*(M+1)]
dp[0][0]=0
# dp[m][s]:=n個目まででsを開けるために必要な最小コスト
def list2int(A):
    res=0
    for a in A:
        res+=2**(a-1)
    return res
    
for m in range(M):
    a,b=f()
    c=list2int(list(f()))
    for i in range(1<<N):
        # 次のカギ買った
        dp[m+1][i|c]=min(dp[m][i]+a,dp[m+1][i|c])
        # やめといた
        dp[m+1][i]=min(dp[m][i],dp[m+1][i])
res=dp[M][(1<<N)-1]
print(res if res<INF else -1)