N, M = (int(i) for i in input().split())
cos = [0] * M
bit = [0] * M
for i in range(M):
    a, b = (int(j) for j in input().split())
    cos[i] = a
    c = [int(j) for j in input().split()]
    bit[i] = sum([2 ** (j-1) for j in c])

DP = [[float("inf")] * 2**N for counter1 in range(M+1)]
for i in range(M):
    DP[i][0] = 0

for i in range(M):
    a = cos[i]
    bi = bit[i]
    for j in range(2**N):
        DP[i+1][j|bi] = min(DP[i+1][j|bi], DP[i][j] + a)
        DP[i+1][j] = min(DP[i+1][j], DP[i][j])

ans = DP[M][2**N-1]
if ans == float("inf"):
    print(-1)
else:
    print(ans) int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N, M = (int(i) for i in input().split()) N (int(i) for i in input().split()) M cos = [0] * M cos [0] * M [0] 0 M bit = [0] * M bit [0] * M [0] 0 M for i in range(M):
    a, b = (int(j) for j in input().split())
    cos[i] = a
    c = [int(j) for j in input().split()]
    bit[i] = sum([2 ** (j-1) for j in c]) i range(M) range M int(j) for j in input().split() for j in input().split() j input().split() ().split () input split for j in input().split() int(j) int j a, b = (int(j) for j in input().split()) a (int(j) for j in input().split()) b cos[i] = a cos[i] cos i a int(j) for j in input().split() for j in input().split() j input().split() ().split () input split for j in input().split() int(j) int j c = [int(j) for j in input().split()] c [int(j) for j in input().split()] 2 ** (j-1) for j in c for j in c j c for j in c 2 ** (j-1) 2 j-1 j 1 bit[i] = sum([2 ** (j-1) for j in c]) bit[i] bit i sum([2 ** (j-1) for j in c]) sum [2 ** (j-1) for j in c] [float("inf")] * 2**N for counter1 in range(M+1) for counter1 in range(M+1) counter1 range(M+1) range M+1 M 1 for counter1 in range(M+1) [float("inf")] * 2**N [float("inf")] float("inf") float "inf" 2**N 2 N DP = [[float("inf")] * 2**N for counter1 in range(M+1)] DP [[float("inf")] * 2**N for counter1 in range(M+1)] for i in range(M):
    DP[i][0] = 0 i range(M) range M DP[i][0] = 0 DP[i][0] [i] DP i 0 0 for i in range(M):
    a = cos[i]
    bi = bit[i]
    for j in range(2**N):
        DP[i+1][j|bi] = min(DP[i+1][j|bi], DP[i][j] + a)
        DP[i+1][j] = min(DP[i+1][j], DP[i][j]) i range(M) range M a = cos[i] a cos[i] cos i bi = bit[i] bi bit[i] bit i for j in range(2**N):
        DP[i+1][j|bi] = min(DP[i+1][j|bi], DP[i][j] + a)
        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|bi] = min(DP[i+1][j|bi], DP[i][j] + a) DP[i+1][j|bi] [i+1] DP i+1 i 1 j|bi j bi min(DP[i+1][j|bi], DP[i][j] + a) min DP[i+1][j|bi] [i+1] DP i+1 i 1 j|bi j bi DP[i][j] + a DP[i][j] [i] DP i j a 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][2**N-1] ans DP[M][2**N-1] [M] DP M 2**N-1 2**N 2 N 1 if ans == float("inf"):
    print(-1)
else:
    print(ans) ans == float("inf") ans float("inf") float "inf" print(-1) print -1 print(ans) print ans b = (int(j) for j in input().split()) (int(j) for j in input().split()) b DP = [[float("inf")] * 2**N for counter1 in range(M+1)] [[float("inf")] * 2**N for counter1 in range(M+1)] DP cos = [0] * M [0] * M cos ans = DP[M][2**N-1] DP[M][2**N-1] ans bit = [0] * M [0] * M bit a = cos[i] cos[i] a c = [int(j) for j in input().split()] [int(j) for j in input().split()] c bi = bit[i] bit[i] bi a, b = (int(j) for j in input().split()) (int(j) for j in input().split()) a M = (int(i) for i in input().split()) (int(i) for i in input().split()) M N, M = (int(i) for i in input().split()) (int(i) for i in input().split()) N
N, M = (int(i) for i in input().split())
cos = [0] * M
bit = [0] * M
for i in range(M):
    a, b = (int(j) for j in input().split())
    cos[i] = a
    c = [int(j) for j in input().split()]
    bit[i] = sum([2 ** (j-1) for j in c])

DP = [[float("inf")] * 2**N for counter1 in range(M+1)]
for i in range(M):
    DP[i][0] = 0

for i in range(M):
    a = cos[i]
    bi = bit[i]
    for j in range(2**N):
        DP[i+1][j|bi] = min(DP[i+1][j|bi], DP[i][j] + a)
        DP[i+1][j] = min(DP[i+1][j], DP[i][j])

ans = DP[M][2**N-1]
if ans == float("inf"):
    print(-1)
else:
    print(ans)