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

abcsl = []
for _ in range(m):
    a,b = map(int, input().split())
    cl = list(map(int, input().split()))
    abcsl.append((a,b,cl))

# dp = [ [10**9]*(2**n) for _ in range(m) ]
dp = [10**9]*(2**n)
dp[0] = 0
for a,b,cl in abcsl:
    b_bit = 0
    for c in cl:
        b_bit += 2**(c-1)
    for i in range(2**n):
        dp[i|b_bit] = min(dp[i]+a, dp[i|b_bit])

if dp[2**n-1] == 10**9:
    print(-1)
else:
    print(dp[2**n-1]) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m abcsl = [] abcsl [] for _ in range(m):
    a,b = map(int, input().split())
    cl = list(map(int, input().split()))
    abcsl.append((a,b,cl))

# dp = [ [10**9]*(2**n) for _ in range(m) ] _ range(m) range m a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b cl = list(map(int, input().split())) cl list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split abcsl.append((a,b,cl)) abcsl.append abcsl append (a,b,cl) a b cl dp = [10**9]*(2**n) dp [10**9]*(2**n) [10**9] 10**9 10 9 2**n 2 n dp[0] = 0 dp[0] dp 0 0 for a,b,cl in abcsl:
    b_bit = 0
    for c in cl:
        b_bit += 2**(c-1)
    for i in range(2**n):
        dp[i|b_bit] = min(dp[i]+a, dp[i|b_bit]) a b cl abcsl b_bit = 0 b_bit 0 for c in cl:
        b_bit += 2**(c-1)
     c cl b_bit += 2**(c-1) b_bit 2**(c-1) 2 c-1 c 1 for i in range(2**n):
        dp[i|b_bit] = min(dp[i]+a, dp[i|b_bit]) i range(2**n) range 2**n 2 n dp[i|b_bit] = min(dp[i]+a, dp[i|b_bit]) dp[i|b_bit] dp i|b_bit i b_bit min(dp[i]+a, dp[i|b_bit]) min dp[i]+a dp[i] dp i a dp[i|b_bit] dp i|b_bit i b_bit if dp[2**n-1] == 10**9:
    print(-1)
else:
    print(dp[2**n-1]) dp[2**n-1] == 10**9 dp[2**n-1] dp 2**n-1 2**n 2 n 1 10**9 10 9 print(-1) print -1 print(dp[2**n-1]) print dp[2**n-1] dp 2**n-1 2**n 2 n 1 abcsl = [] [] abcsl cl = list(map(int, input().split())) list(map(int, input().split())) cl dp = [10**9]*(2**n) [10**9]*(2**n) dp b_bit = 0 0 b_bit b = map(int, input().split()) map(int, input().split()) b a,b = map(int, input().split()) map(int, input().split()) a b_bit += 2**(c-1) 2**(c-1) b_bit n,m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m
n,m = map(int, input().split())

abcsl = []
for _ in range(m):
    a,b = map(int, input().split())
    cl = list(map(int, input().split()))
    abcsl.append((a,b,cl))

# dp = [ [10**9]*(2**n) for _ in range(m) ]
dp = [10**9]*(2**n)
dp[0] = 0
for a,b,cl in abcsl:
    b_bit = 0
    for c in cl:
        b_bit += 2**(c-1)
    for i in range(2**n):
        dp[i|b_bit] = min(dp[i]+a, dp[i|b_bit])

if dp[2**n-1] == 10**9:
    print(-1)
else:
    print(dp[2**n-1])