N, M = map(int, input().split())
a = [0]*M
b = [0]*M
c = [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    cc = list(map(int, input().split()))
    for ccc in cc:
        ccc -= 1
        c[i] += (1 << ccc)

INF = float('inf')
dp = [[INF]*5000 for _ in range(M+1)]
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])
        nj = j | c[i]
        dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + a[i])
if dp[M][(1 << N)-1] == INF:
    print(-1)
else:
    print(dp[M][(1 << N)-1]) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M a = [0]*M a [0]*M [0] 0 M b = [0]*M b [0]*M [0] 0 M c = [0]*M c [0]*M [0] 0 M for i in range(M):
    a[i], b[i] = map(int, input().split())
    cc = list(map(int, input().split()))
    for ccc in cc:
        ccc -= 1
        c[i] += (1 << ccc) i range(M) range M a[i], b[i] = map(int, input().split()) a[i] a i map(int, input().split()) map int input().split() ().split () input split b[i] b i cc = list(map(int, input().split())) cc list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for ccc in cc:
        ccc -= 1
        c[i] += (1 << ccc) ccc cc ccc -= 1 ccc 1 c[i] += (1 << ccc) c[i] c i 1 << ccc 1 ccc INF = float('inf') INF float('inf') float 'inf' [INF]*5000 for _ in range(M+1) for _ in range(M+1) _ range(M+1) range M+1 M 1 for _ in range(M+1) [INF]*5000 [INF] INF 5000 dp = [[INF]*5000 for _ in range(M+1)] dp [[INF]*5000 for _ in range(M+1)] 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])
        nj = j | c[i]
        dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + a[i]) i range(M) range M for j in range((1 << N)):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        nj = j | c[i]
        dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + a[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 nj = j | c[i] nj j | c[i] j c[i] c i dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + a[i]) dp[i+1][nj] [i+1] dp i+1 i 1 nj min(dp[i+1][nj], dp[i][j] + a[i]) min dp[i+1][nj] [i+1] dp i+1 i 1 nj dp[i][j] + a[i] dp[i][j] [i] dp i j a[i] a i if dp[M][(1 << N)-1] == INF:
    print(-1)
else:
    print(dp[M][(1 << N)-1]) dp[M][(1 << N)-1] == INF dp[M][(1 << N)-1] [M] dp M (1 << N)-1 1 << N 1 N 1 INF print(-1) print -1 print(dp[M][(1 << N)-1]) print dp[M][(1 << N)-1] [M] dp M (1 << N)-1 1 << N 1 N 1 N, M = map(int, input().split()) map(int, input().split()) N a = [0]*M [0]*M a ccc -= 1 1 ccc c = [0]*M [0]*M c INF = float('inf') float('inf') INF M = map(int, input().split()) map(int, input().split()) M nj = j | c[i] j | c[i] nj cc = list(map(int, input().split())) list(map(int, input().split())) cc b = [0]*M [0]*M b dp = [[INF]*5000 for _ in range(M+1)] [[INF]*5000 for _ in range(M+1)] dp
N, M = map(int, input().split())
a = [0]*M
b = [0]*M
c = [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    cc = list(map(int, input().split()))
    for ccc in cc:
        ccc -= 1
        c[i] += (1 << ccc)

INF = float('inf')
dp = [[INF]*5000 for _ in range(M+1)]
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])
        nj = j | c[i]
        dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + a[i])
if dp[M][(1 << N)-1] == INF:
    print(-1)
else:
    print(dp[M][(1 << N)-1])
