n, m = map(int, input().split())
a = [None]*m
c = [0]*m
for i in range(m):
    a[i], b = map(int, input().split())
    ls = list(map(int,input().split()))
    for j in ls:
        c[i] |= 1<<(j-1)
n2 = 1<<n
dp = [1e9]*(n2)
dp[0] = 0
for i in range(m):
    for S in range(n2):
        if dp[S|c[i]] > dp[S]+a[i]:
            dp[S|c[i]] = dp[S]+a[i]
if dp[(n2)-1] < 1e9:
    print(dp[(n2)-1])
else:
    print(-1) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a = [None]*m a [None]*m [None] None m c = [0]*m c [0]*m [0] 0 m for i in range(m):
    a[i], b = map(int, input().split())
    ls = list(map(int,input().split()))
    for j in ls:
        c[i] |= 1<<(j-1) i range(m) range m a[i], b = map(int, input().split()) a[i] a i map(int, input().split()) map int input().split() ().split () input split b ls = list(map(int,input().split())) ls list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in ls:
        c[i] |= 1<<(j-1) j ls c[i] |= 1<<(j-1) c[i] c i 1<<(j-1) 1 j-1 j 1 n2 = 1<<n n2 1<<n 1 n dp = [1e9]*(n2) dp [1e9]*(n2) [1e9] 1e9 n2 dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    for S in range(n2):
        if dp[S|c[i]] > dp[S]+a[i]:
            dp[S|c[i]] = dp[S]+a[i] i range(m) range m for S in range(n2):
        if dp[S|c[i]] > dp[S]+a[i]:
            dp[S|c[i]] = dp[S]+a[i] S range(n2) range n2 if dp[S|c[i]] > dp[S]+a[i]:
            dp[S|c[i]] = dp[S]+a[i] dp[S|c[i]] > dp[S]+a[i] dp[S|c[i]] dp S|c[i] S c[i] c i dp[S]+a[i] dp[S] dp S a[i] a i dp[S|c[i]] = dp[S]+a[i] dp[S|c[i]] dp S|c[i] S c[i] c i dp[S]+a[i] dp[S] dp S a[i] a i if dp[(n2)-1] < 1e9:
    print(dp[(n2)-1])
else:
    print(-1) dp[(n2)-1] < 1e9 dp[(n2)-1] dp (n2)-1 n2 1 1e9 print(dp[(n2)-1]) print dp[(n2)-1] dp (n2)-1 n2 1 print(-1) print -1 c = [0]*m [0]*m c b = map(int, input().split()) map(int, input().split()) b n2 = 1<<n 1<<n n2 dp = [1e9]*(n2) [1e9]*(n2) dp n, m = map(int, input().split()) map(int, input().split()) n ls = list(map(int,input().split())) list(map(int,input().split())) ls m = map(int, input().split()) map(int, input().split()) m a = [None]*m [None]*m a
n, m = map(int, input().split())
a = [None]*m
c = [0]*m
for i in range(m):
    a[i], b = map(int, input().split())
    ls = list(map(int,input().split()))
    for j in ls:
        c[i] |= 1<<(j-1)
n2 = 1<<n
dp = [1e9]*(n2)
dp[0] = 0
for i in range(m):
    for S in range(n2):
        if dp[S|c[i]] > dp[S]+a[i]:
            dp[S|c[i]] = dp[S]+a[i]
if dp[(n2)-1] < 1e9:
    print(dp[(n2)-1])
else:
    print(-1)