import sys;input=sys.stdin.readline
N, M = map(int, input().split())
inf = 10**18
dp = [inf]*(1<<N)
dp[0] = 0
for i in range(M):
    a, b = map(int, input().split())
    Cs = list(map(int, input().split()))
    bb = 0
    for c in Cs:
        bb += 2**(c-1)
    for x in range((1<<N)-1, -1, -1):
        dp[bb|x] = min(dp[x]+a, dp[bb|x])

#print(dp)
r = dp[(1<<N)-1]
if r != inf:
    print(dp[(1<<N)-1])
else:
    print(-1) import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M inf = 10**18 inf 10**18 10 18 dp = [inf]*(1<<N) dp [inf]*(1<<N) [inf] inf 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    a, b = map(int, input().split())
    Cs = list(map(int, input().split()))
    bb = 0
    for c in Cs:
        bb += 2**(c-1)
    for x in range((1<<N)-1, -1, -1):
        dp[bb|x] = min(dp[x]+a, dp[bb|x])

#print(dp) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b Cs = list(map(int, input().split())) Cs list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bb = 0 bb 0 for c in Cs:
        bb += 2**(c-1)
     c Cs bb += 2**(c-1) bb 2**(c-1) 2 c-1 c 1 for x in range((1<<N)-1, -1, -1):
        dp[bb|x] = min(dp[x]+a, dp[bb|x])

#print(dp) x range((1<<N)-1, -1, -1) range (1<<N)-1 1<<N 1 N 1 -1 -1 dp[bb|x] = min(dp[x]+a, dp[bb|x]) dp[bb|x] dp bb|x bb x min(dp[x]+a, dp[bb|x]) min dp[x]+a dp[x] dp x a dp[bb|x] dp bb|x bb x r = dp[(1<<N)-1] r dp[(1<<N)-1] dp (1<<N)-1 1<<N 1 N 1 if r != inf:
    print(dp[(1<<N)-1])
else:
    print(-1) r != inf r inf print(dp[(1<<N)-1]) print dp[(1<<N)-1] dp (1<<N)-1 1<<N 1 N 1 print(-1) print -1 Cs = list(map(int, input().split())) list(map(int, input().split())) Cs input=sys.stdin.readline sys.stdin.readline input r = dp[(1<<N)-1] dp[(1<<N)-1] r dp = [inf]*(1<<N) [inf]*(1<<N) dp a, b = map(int, input().split()) map(int, input().split()) a N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M bb = 0 0 bb bb += 2**(c-1) 2**(c-1) bb inf = 10**18 10**18 inf b = map(int, input().split()) map(int, input().split()) b
import sys;input=sys.stdin.readline
N, M = map(int, input().split())
inf = 10**18
dp = [inf]*(1<<N)
dp[0] = 0
for i in range(M):
    a, b = map(int, input().split())
    Cs = list(map(int, input().split()))
    bb = 0
    for c in Cs:
        bb += 2**(c-1)
    for x in range((1<<N)-1, -1, -1):
        dp[bb|x] = min(dp[x]+a, dp[bb|x])

#print(dp)
r = dp[(1<<N)-1]
if r != inf:
    print(dp[(1<<N)-1])
else:
    print(-1)
