import sys
def S(): return sys.stdin.readline().rstrip()

N,M = map(int,S().split())
AB = []
C = []
for _ in range(M):
    AB.append(tuple(int(i) for i in S().split()))
    C.append(sum(1<<(int(i)-1) for i in S().split()))

dp = [float('inf')]*(1<<N)
dp[0] = 0

for i in range(1<<N):
    for j in range(M):
        a,b = AB[j]
        c = C[j]
        dp[i|c] = min(dp[i|c],dp[i]+a)

if dp[-1] == float('inf'):
    print(-1)
else:
    print(dp[-1]) import sys sys def S(): return sys.stdin.readline().rstrip() S N,M = map(int,S().split()) N map(int,S().split()) map int S().split() ().split () S split M AB = [] AB [] C = [] C [] for _ in range(M):
    AB.append(tuple(int(i) for i in S().split()))
    C.append(sum(1<<(int(i)-1) for i in S().split())) _ range(M) range M AB.append(tuple(int(i) for i in S().split())) AB.append AB append tuple(int(i) for i in S().split()) tuple int(i) int i C.append(sum(1<<(int(i)-1) for i in S().split())) C.append C append sum(1<<(int(i)-1) for i in S().split()) sum 1<<(int(i)-1) 1 int(i)-1 int(i) int i 1 dp = [float('inf')]*(1<<N) dp [float('inf')]*(1<<N) [float('inf')] float('inf') float 'inf' 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for i in range(1<<N):
    for j in range(M):
        a,b = AB[j]
        c = C[j]
        dp[i|c] = min(dp[i|c],dp[i]+a) i range(1<<N) range 1<<N 1 N for j in range(M):
        a,b = AB[j]
        c = C[j]
        dp[i|c] = min(dp[i|c],dp[i]+a) j range(M) range M a,b = AB[j] a AB[j] AB j b c = C[j] c C[j] C j dp[i|c] = min(dp[i|c],dp[i]+a) dp[i|c] dp i|c i c min(dp[i|c],dp[i]+a) min dp[i|c] dp i|c i c dp[i]+a dp[i] dp i a if dp[-1] == float('inf'):
    print(-1)
else:
    print(dp[-1]) dp[-1] == float('inf') dp[-1] dp -1 float('inf') float 'inf' print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 b = AB[j] AB[j] b c = C[j] C[j] c M = map(int,S().split()) map(int,S().split()) M C = [] [] C dp = [float('inf')]*(1<<N) [float('inf')]*(1<<N) dp N,M = map(int,S().split()) map(int,S().split()) N a,b = AB[j] AB[j] a AB = [] [] AB def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S
import sys
def S(): return sys.stdin.readline().rstrip()

N,M = map(int,S().split())
AB = []
C = []
for _ in range(M):
    AB.append(tuple(int(i) for i in S().split()))
    C.append(sum(1<<(int(i)-1) for i in S().split()))

dp = [float('inf')]*(1<<N)
dp[0] = 0

for i in range(1<<N):
    for j in range(M):
        a,b = AB[j]
        c = C[j]
        dp[i|c] = min(dp[i|c],dp[i]+a)

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