INF = 10 ** 18
N, M = map(int, input().split())
dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)]
cost = [0] * M
bit = [0] * M
for i in range(M):
    cost[i], b = map(int, input().split())
    c = list(map(int, input().split()))
    d = 0
    for j in range(len(c)):
        d |= 1 << (c[j] - 1)
    bit[i] = d

dp[0][0] = 0
for i in range(M):
    for j in range(1 << N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        to = bit[i] | j
        dp[i + 1][to] = min(dp[i + 1][to], dp[i][j] + cost[i])

ans = dp[M][(1 << N) - 1]
if ans == INF:
    print(-1)
else:
    print(ans) INF = 10 ** 18 INF 10 ** 18 10 18 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M [INF for _ in range(1 << 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 for _ in range(1 << N)] dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)] dp [[INF for _ in range(1 << N)] for _ in range(M + 1)] cost = [0] * M cost [0] * M [0] 0 M bit = [0] * M bit [0] * M [0] 0 M for i in range(M):
    cost[i], b = map(int, input().split())
    c = list(map(int, input().split()))
    d = 0
    for j in range(len(c)):
        d |= 1 << (c[j] - 1)
    bit[i] = d i range(M) range M cost[i], b = map(int, input().split()) cost[i] cost i map(int, input().split()) map int input().split() ().split () input split b c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split d = 0 d 0 for j in range(len(c)):
        d |= 1 << (c[j] - 1)
     j range(len(c)) range len(c) len c d |= 1 << (c[j] - 1) d 1 << (c[j] - 1) 1 c[j] - 1 c[j] c j 1 bit[i] = d bit[i] bit i d dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    for j in range(1 << N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        to = bit[i] | j
        dp[i + 1][to] = min(dp[i + 1][to], dp[i][j] + cost[i]) i range(M) range M for j in range(1 << N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        to = bit[i] | j
        dp[i + 1][to] = min(dp[i + 1][to], dp[i][j] + cost[i]) j range(1 << N) range 1 << N 1 N 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 to = bit[i] | j to bit[i] | j bit[i] bit i j dp[i + 1][to] = min(dp[i + 1][to], dp[i][j] + cost[i]) dp[i + 1][to] [i + 1] dp i + 1 i 1 to min(dp[i + 1][to], dp[i][j] + cost[i]) min dp[i + 1][to] [i + 1] dp i + 1 i 1 to dp[i][j] + cost[i] dp[i][j] [i] dp i j cost[i] cost i 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 d = 0 0 d N, M = map(int, input().split()) map(int, input().split()) N cost = [0] * M [0] * M cost to = bit[i] | j bit[i] | j to INF = 10 ** 18 10 ** 18 INF M = map(int, input().split()) map(int, input().split()) M b = map(int, input().split()) map(int, input().split()) b bit = [0] * M [0] * M bit d |= 1 << (c[j] - 1) 1 << (c[j] - 1) d c = list(map(int, input().split())) list(map(int, input().split())) c ans = dp[M][(1 << N) - 1] dp[M][(1 << N) - 1] ans dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)] [[INF for _ in range(1 << N)] for _ in range(M + 1)] dp
INF = 10 ** 18
N, M = map(int, input().split())
dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)]
cost = [0] * M
bit = [0] * M
for i in range(M):
    cost[i], b = map(int, input().split())
    c = list(map(int, input().split()))
    d = 0
    for j in range(len(c)):
        d |= 1 << (c[j] - 1)
    bit[i] = d

dp[0][0] = 0
for i in range(M):
    for j in range(1 << N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        to = bit[i] | j
        dp[i + 1][to] = min(dp[i + 1][to], dp[i][j] + cost[i])

ans = dp[M][(1 << N) - 1]
if ans == INF:
    print(-1)
else:
    print(ans)
