N, M = map(int, input().split())
key = []
for i in range(M):
    a, b = map(int, input().split())
    s = 0
    C = list(map(int, input().split()))
    for c in C:
        c -= 1
        s |= 1 << c
    key.append((s, a))

dp = [float('inf')] * (1 << N)
dp[0] = 0
for s in range(1 << N):
    for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)
ans = dp[-1]
if ans != float('inf'):
    print(ans)
else:
    print(-1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M key = [] key [] for i in range(M):
    a, b = map(int, input().split())
    s = 0
    C = list(map(int, input().split()))
    for c in C:
        c -= 1
        s |= 1 << c
    key.append((s, a)) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b s = 0 s 0 C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for c in C:
        c -= 1
        s |= 1 << c
     c C c -= 1 c 1 s |= 1 << c s 1 << c 1 c key.append((s, a)) key.append key append (s, a) s a dp = [float('inf')] * (1 << N) dp [float('inf')] * (1 << N) [float('inf')] float('inf') float 'inf' 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for s in range(1 << N):
    for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost) s range(1 << N) range 1 << N 1 N for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost) i range(M) range M t = s | key[i][0] t s | key[i][0] s key[i][0] [i] key i 0 cost = dp[s] + key[i][1] cost dp[s] + key[i][1] dp[s] dp s key[i][1] [i] key i 1 dp[t] = min(dp[t], cost) dp[t] dp t min(dp[t], cost) min dp[t] dp t cost ans = dp[-1] ans dp[-1] dp -1 if ans != float('inf'):
    print(ans)
else:
    print(-1) ans != float('inf') ans float('inf') float 'inf' print(ans) print ans print(-1) print -1 cost = dp[s] + key[i][1] dp[s] + key[i][1] cost s = 0 0 s a, b = map(int, input().split()) map(int, input().split()) a N, M = map(int, input().split()) map(int, input().split()) N b = map(int, input().split()) map(int, input().split()) b s |= 1 << c 1 << c s ans = dp[-1] dp[-1] ans C = list(map(int, input().split())) list(map(int, input().split())) C t = s | key[i][0] s | key[i][0] t c -= 1 1 c dp = [float('inf')] * (1 << N) [float('inf')] * (1 << N) dp M = map(int, input().split()) map(int, input().split()) M key = [] [] key
N, M = map(int, input().split())
key = []
for i in range(M):
    a, b = map(int, input().split())
    s = 0
    C = list(map(int, input().split()))
    for c in C:
        c -= 1
        s |= 1 << c
    key.append((s, a))

dp = [float('inf')] * (1 << N)
dp[0] = 0
for s in range(1 << N):
    for i in range(M):
        t = s | key[i][0]
        cost = dp[s] + key[i][1]
        dp[t] = min(dp[t], cost)
ans = dp[-1]
if ans != float('inf'):
    print(ans)
else:
    print(-1)
