N, M = map(int, input().split())

dp = [float('inf')] * (1 << N)
dp[0] = 0

u = 1 << N
for i in range(M):
    a, b = map(int, input().split())
    c = sum(1 << (x - 1) for x in map(int, input().split()))

    for j in range(u):
        dp[c | j] = min(dp[c | j], dp[j] + a)


if dp[-1] != float('inf'):
    print(dp[-1])
else:
    print(-1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M 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 u = 1 << N u 1 << N 1 N for i in range(M):
    a, b = map(int, input().split())
    c = sum(1 << (x - 1) for x in map(int, input().split()))

    for j in range(u):
        dp[c | j] = min(dp[c | j], dp[j] + 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 c = sum(1 << (x - 1) for x in map(int, input().split())) c sum(1 << (x - 1) for x in map(int, input().split())) sum 1 << (x - 1) 1 x - 1 x 1 for j in range(u):
        dp[c | j] = min(dp[c | j], dp[j] + a) j range(u) range u dp[c | j] = min(dp[c | j], dp[j] + a) dp[c | j] dp c | j c j min(dp[c | j], dp[j] + a) min dp[c | j] dp c | j c j dp[j] + a dp[j] dp j a if dp[-1] != float('inf'):
    print(dp[-1])
else:
    print(-1) dp[-1] != float('inf') dp[-1] dp -1 float('inf') float 'inf' print(dp[-1]) print dp[-1] dp -1 print(-1) print -1 M = map(int, input().split()) map(int, input().split()) M dp = [float('inf')] * (1 << N) [float('inf')] * (1 << N) dp N, M = map(int, input().split()) map(int, input().split()) N c = sum(1 << (x - 1) for x in map(int, input().split())) sum(1 << (x - 1) for x in map(int, input().split())) c a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b u = 1 << N 1 << N u
N, M = map(int, input().split())

dp = [float('inf')] * (1 << N)
dp[0] = 0

u = 1 << N
for i in range(M):
    a, b = map(int, input().split())
    c = sum(1 << (x - 1) for x in map(int, input().split()))

    for j in range(u):
        dp[c | j] = min(dp[c | j], dp[j] + a)


if dp[-1] != float('inf'):
    print(dp[-1])
else:
    print(-1)
