n, m = map(int, input().split())
a, b, c = [], [], []
for i in range(m):
    ai, bi = map(int, input().split())
    a.append(ai); b.append(bi)
    ci = list(map(int, input().split()))
    c.append(ci)

dp = [[10**9 for j in range(2**n)] for i in range(m)]
key = 0
for i in range(b[0]):
    key += 1<<(c[0][i]-1)
dp[0][key] = a[0]
dp[0][0] = 0

for i in range(1, m):
    ai, bi, ci = a[i], b[i], c[i]
    key = 0
    for j in range(bi):
        key += 1<<(ci[j]-1)
    for j in range(2**n):
        dp[i][j|key] = min(dp[i-1][j|key], dp[i-1][j]+ai, dp[i][j|key])
    for j in range(2**n):
        dp[i][j] = min(dp[i-1][j], dp[i][j])

if dp[m-1][2**n-1] == 10**9:
    print(-1)
else:
    print(dp[m-1][2**n-1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a, b, c = [], [], [] a [] b [] c [] for i in range(m):
    ai, bi = map(int, input().split())
    a.append(ai); b.append(bi)
    ci = list(map(int, input().split()))
    c.append(ci) i range(m) range m ai, bi = map(int, input().split()) ai map(int, input().split()) map int input().split() ().split () input split bi a.append(ai) a.append a append ai b.append(bi) b.append b append bi ci = list(map(int, input().split())) ci list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c.append(ci) c.append c append ci [10**9 for j in range(2**n)] for i in range(m) for i in range(m) i range(m) range m for i in range(m) [10**9 for j in range(2**n)] dp = [[10**9 for j in range(2**n)] for i in range(m)] dp [[10**9 for j in range(2**n)] for i in range(m)] key = 0 key 0 for i in range(b[0]):
    key += 1<<(c[0][i]-1) i range(b[0]) range b[0] b 0 key += 1<<(c[0][i]-1) key 1<<(c[0][i]-1) 1 c[0][i]-1 c[0][i] [0] c 0 i 1 dp[0][key] = a[0] dp[0][key] [0] dp 0 key a[0] a 0 dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(1, m):
    ai, bi, ci = a[i], b[i], c[i]
    key = 0
    for j in range(bi):
        key += 1<<(ci[j]-1)
    for j in range(2**n):
        dp[i][j|key] = min(dp[i-1][j|key], dp[i-1][j]+ai, dp[i][j|key])
    for j in range(2**n):
        dp[i][j] = min(dp[i-1][j], dp[i][j]) i range(1, m) range 1 m ai, bi, ci = a[i], b[i], c[i] ai a[i] a i bi b[i] b i ci c[i] c i key = 0 key 0 for j in range(bi):
        key += 1<<(ci[j]-1)
     j range(bi) range bi key += 1<<(ci[j]-1) key 1<<(ci[j]-1) 1 ci[j]-1 ci[j] ci j 1 for j in range(2**n):
        dp[i][j|key] = min(dp[i-1][j|key], dp[i-1][j]+ai, dp[i][j|key])
     j range(2**n) range 2**n 2 n dp[i][j|key] = min(dp[i-1][j|key], dp[i-1][j]+ai, dp[i][j|key]) dp[i][j|key] [i] dp i j|key j key min(dp[i-1][j|key], dp[i-1][j]+ai, dp[i][j|key]) min dp[i-1][j|key] [i-1] dp i-1 i 1 j|key j key dp[i-1][j]+ai dp[i-1][j] [i-1] dp i-1 i 1 j ai dp[i][j|key] [i] dp i j|key j key for j in range(2**n):
        dp[i][j] = min(dp[i-1][j], dp[i][j]) j range(2**n) range 2**n 2 n dp[i][j] = min(dp[i-1][j], dp[i][j]) dp[i][j] [i] dp i j min(dp[i-1][j], dp[i][j]) min dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j] [i] dp i j if dp[m-1][2**n-1] == 10**9:
    print(-1)
else:
    print(dp[m-1][2**n-1]) dp[m-1][2**n-1] == 10**9 dp[m-1][2**n-1] [m-1] dp m-1 m 1 2**n-1 2**n 2 n 1 10**9 10 9 print(-1) print -1 print(dp[m-1][2**n-1]) print dp[m-1][2**n-1] [m-1] dp m-1 m 1 2**n-1 2**n 2 n 1 c = [], [], [] [] c m = map(int, input().split()) map(int, input().split()) m ai, bi = map(int, input().split()) map(int, input().split()) ai bi = map(int, input().split()) map(int, input().split()) bi dp = [[10**9 for j in range(2**n)] for i in range(m)] [[10**9 for j in range(2**n)] for i in range(m)] dp a, b, c = [], [], [] [] a b, c = [], [], [] [] b bi, ci = a[i], b[i], c[i] b[i] bi ci = list(map(int, input().split())) list(map(int, input().split())) ci key += 1<<(c[0][i]-1) 1<<(c[0][i]-1) key key += 1<<(ci[j]-1) 1<<(ci[j]-1) key key = 0 0 key ai, bi, ci = a[i], b[i], c[i] a[i] ai n, m = map(int, input().split()) map(int, input().split()) n ci = a[i], b[i], c[i] c[i] ci key = 0 0 key
n, m = map(int, input().split())
a, b, c = [], [], []
for i in range(m):
    ai, bi = map(int, input().split())
    a.append(ai); b.append(bi)
    ci = list(map(int, input().split()))
    c.append(ci)

dp = [[10**9 for j in range(2**n)] for i in range(m)]
key = 0
for i in range(b[0]):
    key += 1<<(c[0][i]-1)
dp[0][key] = a[0]
dp[0][0] = 0

for i in range(1, m):
    ai, bi, ci = a[i], b[i], c[i]
    key = 0
    for j in range(bi):
        key += 1<<(ci[j]-1)
    for j in range(2**n):
        dp[i][j|key] = min(dp[i-1][j|key], dp[i-1][j]+ai, dp[i][j|key])
    for j in range(2**n):
        dp[i][j] = min(dp[i-1][j], dp[i][j])

if dp[m-1][2**n-1] == 10**9:
    print(-1)
else:
    print(dp[m-1][2**n-1])