#142_E
n, m = map(int, input().split())
inf = 10 ** 10
keys = [0 for _ in range(m)]
A = [] 

for i in range(m):
    a, _ = map(int, input().split())
    keys[i] = sum([2 ** (int(c) - 1) for c in input().split()])
    A.append(a)
    
dp = [[inf for _ in range(2 ** n)] for _ in range(m+1)]
dp[0][0] = 0
for i in range(0, m):
    for key in range(2 ** n):
        dp[i+1][key] = dp[i][key]
        
    for key in range(2 ** n):
        dp[i+1][key | keys[i]] = min(dp[i+1][key | keys[i]],
                                     dp[i][key] + A[i])

if dp[m][2 ** n - 1] == inf:
    print(-1)
else:
    print(dp[m][2 ** n - 1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m inf = 10 ** 10 inf 10 ** 10 10 10 0 for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) 0 keys = [0 for _ in range(m)] keys [0 for _ in range(m)] A = [] A [] for i in range(m):
    a, _ = map(int, input().split())
    keys[i] = sum([2 ** (int(c) - 1) for c in input().split()])
    A.append(a)
     i range(m) range m a, _ = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split _ 2 ** (int(c) - 1) for c in input().split() for c in input().split() c input().split() ().split () input split for c in input().split() 2 ** (int(c) - 1) 2 int(c) - 1 int(c) int c 1 keys[i] = sum([2 ** (int(c) - 1) for c in input().split()]) keys[i] keys i sum([2 ** (int(c) - 1) for c in input().split()]) sum [2 ** (int(c) - 1) for c in input().split()] A.append(a) A.append A append a [inf for _ in range(2 ** n)] for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [inf for _ in range(2 ** n)] dp = [[inf for _ in range(2 ** n)] for _ in range(m+1)] dp [[inf for _ in range(2 ** n)] for _ in range(m+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(0, m):
    for key in range(2 ** n):
        dp[i+1][key] = dp[i][key]
        
    for key in range(2 ** n):
        dp[i+1][key | keys[i]] = min(dp[i+1][key | keys[i]],
                                     dp[i][key] + A[i]) i range(0, m) range 0 m for key in range(2 ** n):
        dp[i+1][key] = dp[i][key]
        
     key range(2 ** n) range 2 ** n 2 n dp[i+1][key] = dp[i][key] dp[i+1][key] [i+1] dp i+1 i 1 key dp[i][key] [i] dp i key for key in range(2 ** n):
        dp[i+1][key | keys[i]] = min(dp[i+1][key | keys[i]],
                                     dp[i][key] + A[i]) key range(2 ** n) range 2 ** n 2 n dp[i+1][key | keys[i]] = min(dp[i+1][key | keys[i]],
                                     dp[i][key] + A[i]) dp[i+1][key | keys[i]] [i+1] dp i+1 i 1 key | keys[i] key keys[i] keys i min(dp[i+1][key | keys[i]],
                                     dp[i][key] + A[i]) min dp[i+1][key | keys[i]] [i+1] dp i+1 i 1 key | keys[i] key keys[i] keys i dp[i][key] + A[i] dp[i][key] [i] dp i key A[i] A i if dp[m][2 ** n - 1] == inf:
    print(-1)
else:
    print(dp[m][2 ** n - 1]) dp[m][2 ** n - 1] == inf dp[m][2 ** n - 1] [m] dp m 2 ** n - 1 2 ** n 2 n 1 inf print(-1) print -1 print(dp[m][2 ** n - 1]) print dp[m][2 ** n - 1] [m] dp m 2 ** n - 1 2 ** n 2 n 1 keys = [0 for _ in range(m)] [0 for _ in range(m)] keys inf = 10 ** 10 10 ** 10 inf A = [] [] A m = map(int, input().split()) map(int, input().split()) m _ = map(int, input().split()) map(int, input().split()) _ n, m = map(int, input().split()) map(int, input().split()) n dp = [[inf for _ in range(2 ** n)] for _ in range(m+1)] [[inf for _ in range(2 ** n)] for _ in range(m+1)] dp a, _ = map(int, input().split()) map(int, input().split()) a
#142_E
n, m = map(int, input().split())
inf = 10 ** 10
keys = [0 for _ in range(m)]
A = [] 

for i in range(m):
    a, _ = map(int, input().split())
    keys[i] = sum([2 ** (int(c) - 1) for c in input().split()])
    A.append(a)
    
dp = [[inf for _ in range(2 ** n)] for _ in range(m+1)]
dp[0][0] = 0
for i in range(0, m):
    for key in range(2 ** n):
        dp[i+1][key] = dp[i][key]
        
    for key in range(2 ** n):
        dp[i+1][key | keys[i]] = min(dp[i+1][key | keys[i]],
                                     dp[i][key] + A[i])

if dp[m][2 ** n - 1] == inf:
    print(-1)
else:
    print(dp[m][2 ** n - 1])