n, m = map(int, input().split())

A = [0]*m
C = [0]*m
for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    cs = list(map(int, input().split()))
    c = 0
    for c_ in cs:
        c += 1 << (c_-1)
    C[i] = c

dp = [float('inf')]*(1 << n)
dp[0] = 0
for i in range(1 << n):
    for j in range(m):
        c = C[j]
        dp[i|c] = min(dp[i|c], dp[i]+A[j])

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 A = [0]*m A [0]*m [0] 0 m C = [0]*m C [0]*m [0] 0 m for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    cs = list(map(int, input().split()))
    c = 0
    for c_ in cs:
        c += 1 << (c_-1)
    C[i] = c i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A[i] = a A[i] A i a cs = list(map(int, input().split())) cs list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c = 0 c 0 for c_ in cs:
        c += 1 << (c_-1)
     c_ cs c += 1 << (c_-1) c 1 << (c_-1) 1 c_-1 c_ 1 C[i] = c C[i] C i c 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 i in range(1 << n):
    for j in range(m):
        c = C[j]
        dp[i|c] = min(dp[i|c], dp[i]+A[j]) i range(1 << n) range 1 << n 1 n for j in range(m):
        c = C[j]
        dp[i|c] = min(dp[i|c], dp[i]+A[j]) j range(m) range m c = C[j] c C[j] C j dp[i|c] = min(dp[i|c], dp[i]+A[j]) dp[i|c] dp i|c i c min(dp[i|c], dp[i]+A[j]) min dp[i|c] dp i|c i c dp[i]+A[j] dp[i] dp i A[j] A j 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 c = C[j] C[j] c a, b = map(int, input().split()) map(int, input().split()) a cs = list(map(int, input().split())) list(map(int, input().split())) cs c += 1 << (c_-1) 1 << (c_-1) c C = [0]*m [0]*m C b = map(int, input().split()) map(int, input().split()) b m = map(int, input().split()) map(int, input().split()) m A = [0]*m [0]*m A dp = [float('inf')]*(1 << n) [float('inf')]*(1 << n) dp n, m = map(int, input().split()) map(int, input().split()) n c = 0 0 c
n, m = map(int, input().split())

A = [0]*m
C = [0]*m
for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    cs = list(map(int, input().split()))
    c = 0
    for c_ in cs:
        c += 1 << (c_-1)
    C[i] = c

dp = [float('inf')]*(1 << n)
dp[0] = 0
for i in range(1 << n):
    for j in range(m):
        c = C[j]
        dp[i|c] = min(dp[i|c], dp[i]+A[j])

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