# import sys
# sys.setrecursionlimit
getarr = lambda _f: list(map(_f, input().split()))
inf = 10**8 + 1

N, M = getarr(int)

keys = []
key_max = 2**N - 1
for _ in range(M):
    a, b = getarr(int)
    c = getarr(int)
    k = key_max
    for ci in c:
        k -= (1 << (ci - 1))
    keys.append([a, k])
dp = [[inf] * (M + 1) for _ in range(2**N + 1)]
for i in range(M + 1):
    dp[0][i] = 0

for j in range(M):
    for i in range(2**N + 1):
        _cost = keys[j][0]
        _key = keys[j][1]
        dp[i][j + 1] = min(_cost + dp[i & _key][j], dp[i][j])

ans = dp[key_max][M]

print(ans if ans != inf else -1) getarr = lambda _f: list(map(_f, input().split())) getarr lambda _f: list(map(_f, input().split())) list(map(_f, input().split())) list map(_f, input().split()) map _f input().split() ().split () input split _f inf = 10**8 + 1 inf 10**8 + 1 10**8 10 8 1 N, M = getarr(int) N getarr(int) getarr int M keys = [] keys [] key_max = 2**N - 1 key_max 2**N - 1 2**N 2 N 1 for _ in range(M):
    a, b = getarr(int)
    c = getarr(int)
    k = key_max
    for ci in c:
        k -= (1 << (ci - 1))
    keys.append([a, k]) _ range(M) range M a, b = getarr(int) a getarr(int) getarr int b c = getarr(int) c getarr(int) getarr int k = key_max k key_max for ci in c:
        k -= (1 << (ci - 1))
     ci c k -= (1 << (ci - 1)) k 1 << (ci - 1) 1 ci - 1 ci 1 keys.append([a, k]) keys.append keys append [a, k] a k [inf] * (M + 1) for _ in range(2**N + 1) for _ in range(2**N + 1) _ range(2**N + 1) range 2**N + 1 2**N 2 N 1 for _ in range(2**N + 1) [inf] * (M + 1) [inf] inf M + 1 M 1 dp = [[inf] * (M + 1) for _ in range(2**N + 1)] dp [[inf] * (M + 1) for _ in range(2**N + 1)] for i in range(M + 1):
    dp[0][i] = 0 i range(M + 1) range M + 1 M 1 dp[0][i] = 0 dp[0][i] [0] dp 0 i 0 for j in range(M):
    for i in range(2**N + 1):
        _cost = keys[j][0]
        _key = keys[j][1]
        dp[i][j + 1] = min(_cost + dp[i & _key][j], dp[i][j]) j range(M) range M for i in range(2**N + 1):
        _cost = keys[j][0]
        _key = keys[j][1]
        dp[i][j + 1] = min(_cost + dp[i & _key][j], dp[i][j]) i range(2**N + 1) range 2**N + 1 2**N 2 N 1 _cost = keys[j][0] _cost keys[j][0] [j] keys j 0 _key = keys[j][1] _key keys[j][1] [j] keys j 1 dp[i][j + 1] = min(_cost + dp[i & _key][j], dp[i][j]) dp[i][j + 1] [i] dp i j + 1 j 1 min(_cost + dp[i & _key][j], dp[i][j]) min _cost + dp[i & _key][j] _cost dp[i & _key][j] [i & _key] dp i & _key i _key j dp[i][j] [i] dp i j ans = dp[key_max][M] ans dp[key_max][M] [key_max] dp key_max M print(ans if ans != inf else -1) print ans if ans != inf else -1 ans != inf ans inf ans -1 b = getarr(int) getarr(int) b N, M = getarr(int) getarr(int) N key_max = 2**N - 1 2**N - 1 key_max M = getarr(int) getarr(int) M keys = [] [] keys k = key_max key_max k _key = keys[j][1] keys[j][1] _key c = getarr(int) getarr(int) c a, b = getarr(int) getarr(int) a _cost = keys[j][0] keys[j][0] _cost dp = [[inf] * (M + 1) for _ in range(2**N + 1)] [[inf] * (M + 1) for _ in range(2**N + 1)] dp getarr = lambda _f: list(map(_f, input().split())) lambda _f: list(map(_f, input().split())) getarr ans = dp[key_max][M] dp[key_max][M] ans inf = 10**8 + 1 10**8 + 1 inf k -= (1 << (ci - 1)) 1 << (ci - 1) k
# import sys
# sys.setrecursionlimit
getarr = lambda _f: list(map(_f, input().split()))
inf = 10**8 + 1

N, M = getarr(int)

keys = []
key_max = 2**N - 1
for _ in range(M):
    a, b = getarr(int)
    c = getarr(int)
    k = key_max
    for ci in c:
        k -= (1 << (ci - 1))
    keys.append([a, k])
dp = [[inf] * (M + 1) for _ in range(2**N + 1)]
for i in range(M + 1):
    dp[0][i] = 0

for j in range(M):
    for i in range(2**N + 1):
        _cost = keys[j][0]
        _key = keys[j][1]
        dp[i][j + 1] = min(_cost + dp[i & _key][j], dp[i][j])

ans = dp[key_max][M]

print(ans if ans != inf else -1)