INF = 10 ** 10
n, m = map(int, input().split())
dp = [[INF] * (2 ** n) for _ in range(m + 1)]
a = [0] * m
c = [0] * m
for i in range(m):
    a[i], b = map(int, input().split())
    t = 0
    for k in list(map(int, input().split())):
        t += 1 << (k - 1)
    c[i] = t
dp[0][0] = 0
for i in range(m):
    for j in range(2 ** n):
        dp[i + 1][j | c[i]] = min(dp[i + 1][j | c[i]], dp[i][j] + a[i])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
ans = dp[m][(1 << n) - 1]
if ans == INF:
    print(-1)
else:
    print(ans) INF = 10 ** 10 INF 10 ** 10 10 10 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m [INF] * (2 ** n) for _ in range(m + 1) for _ in range(m + 1) _ range(m + 1) range m + 1 m 1 for _ in range(m + 1) [INF] * (2 ** n) [INF] INF 2 ** n 2 n dp = [[INF] * (2 ** n) for _ in range(m + 1)] dp [[INF] * (2 ** n) for _ in range(m + 1)] a = [0] * m a [0] * m [0] 0 m c = [0] * m c [0] * m [0] 0 m for i in range(m):
    a[i], b = map(int, input().split())
    t = 0
    for k in list(map(int, input().split())):
        t += 1 << (k - 1)
    c[i] = t i range(m) range m a[i], b = map(int, input().split()) a[i] a i map(int, input().split()) map int input().split() ().split () input split b t = 0 t 0 for k in list(map(int, input().split())):
        t += 1 << (k - 1)
     k list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split t += 1 << (k - 1) t 1 << (k - 1) 1 k - 1 k 1 c[i] = t c[i] c i t dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    for j in range(2 ** n):
        dp[i + 1][j | c[i]] = min(dp[i + 1][j | c[i]], dp[i][j] + a[i])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) i range(m) range m for j in range(2 ** n):
        dp[i + 1][j | c[i]] = min(dp[i + 1][j | c[i]], dp[i][j] + a[i])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) j range(2 ** n) range 2 ** n 2 n dp[i + 1][j | c[i]] = min(dp[i + 1][j | c[i]], dp[i][j] + a[i]) dp[i + 1][j | c[i]] [i + 1] dp i + 1 i 1 j | c[i] j c[i] c i min(dp[i + 1][j | c[i]], dp[i][j] + a[i]) min dp[i + 1][j | c[i]] [i + 1] dp i + 1 i 1 j | c[i] j c[i] c i dp[i][j] + a[i] dp[i][j] [i] dp i j a[i] a i dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) dp[i + 1][j] [i + 1] dp i + 1 i 1 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 ans = dp[m][(1 << n) - 1] ans dp[m][(1 << n) - 1] [m] dp m (1 << n) - 1 1 << n 1 n 1 if ans == INF:
    print(-1)
else:
    print(ans) ans == INF ans INF print(-1) print -1 print(ans) print ans a = [0] * m [0] * m a b = map(int, input().split()) map(int, input().split()) b ans = dp[m][(1 << n) - 1] dp[m][(1 << n) - 1] ans m = map(int, input().split()) map(int, input().split()) m dp = [[INF] * (2 ** n) for _ in range(m + 1)] [[INF] * (2 ** n) for _ in range(m + 1)] dp c = [0] * m [0] * m c t = 0 0 t t += 1 << (k - 1) 1 << (k - 1) t INF = 10 ** 10 10 ** 10 INF n, m = map(int, input().split()) map(int, input().split()) n
INF = 10 ** 10
n, m = map(int, input().split())
dp = [[INF] * (2 ** n) for _ in range(m + 1)]
a = [0] * m
c = [0] * m
for i in range(m):
    a[i], b = map(int, input().split())
    t = 0
    for k in list(map(int, input().split())):
        t += 1 << (k - 1)
    c[i] = t
dp[0][0] = 0
for i in range(m):
    for j in range(2 ** n):
        dp[i + 1][j | c[i]] = min(dp[i + 1][j | c[i]], dp[i][j] + a[i])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
ans = dp[m][(1 << n) - 1]
if ans == INF:
    print(-1)
else:
    print(ans)
