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 = [10**8+1]*(1<<N)
dp[0] = 0

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

if dp[-1] == 10**8+1:
    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 = [10**8+1]*(1<<N) dp [10**8+1]*(1<<N) [10**8+1] 10**8+1 10**8 10 8 1 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]
        m = i|c
        dp[m] = min(dp[m],dp[i]+a) i range(1<<N) range 1<<N 1 N for j in range(M):
        a,b = AB[j]
        c = C[j]
        m = i|c
        dp[m] = min(dp[m],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 m = i|c m i|c i c dp[m] = min(dp[m],dp[i]+a) dp[m] dp m min(dp[m],dp[i]+a) min dp[m] dp m dp[i]+a dp[i] dp i a if dp[-1] == 10**8+1:
    print(-1)
else:
    print(dp[-1]) dp[-1] == 10**8+1 dp[-1] dp -1 10**8+1 10**8 10 8 1 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 a,b = AB[j] AB[j] a M = map(int,S().split()) map(int,S().split()) M def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S m = i|c i|c m dp = [10**8+1]*(1<<N) [10**8+1]*(1<<N) dp N,M = map(int,S().split()) map(int,S().split()) N AB = [] [] AB c = C[j] C[j] c C = [] [] C b = AB[j] AB[j] b
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 = [10**8+1]*(1<<N)
dp[0] = 0

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

if dp[-1] == 10**8+1:
    print(-1)
else:
    print(dp[-1])