n,m = map(int,input().split())
cost = []
key = []
inf = int(1e9)
for i in range(m):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    cost.append(a)
    cnt = 0
    for j in range(1,n+1):
        if j in c:
           cnt += 2**(n-j)
    key.append(bin(cnt))
dp = [inf]*(2**n)
for i in range(m):
    dp[int(key[i],0)] = min(cost[i],dp[int(key[i],0)])
for i in range(2**n):
    if dp[i] != inf:
        for j in range(m):
            k = int(key[j], 0)
            tar = k | i
            dp[tar] = min(dp[tar], dp[i] + cost[j])
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])


 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m cost = [] cost [] key = [] key [] inf = int(1e9) inf int(1e9) int 1e9 for i in range(m):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    cost.append(a)
    cnt = 0
    for j in range(1,n+1):
        if j in c:
           cnt += 2**(n-j)
    key.append(bin(cnt)) 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 = list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split cost.append(a) cost.append cost append a cnt = 0 cnt 0 for j in range(1,n+1):
        if j in c:
           cnt += 2**(n-j)
     j range(1,n+1) range 1 n+1 n 1 if j in c:
           cnt += 2**(n-j)
     j in c j c cnt += 2**(n-j) cnt 2**(n-j) 2 n-j n j key.append(bin(cnt)) key.append key append bin(cnt) bin cnt dp = [inf]*(2**n) dp [inf]*(2**n) [inf] inf 2**n 2 n for i in range(m):
    dp[int(key[i],0)] = min(cost[i],dp[int(key[i],0)]) i range(m) range m dp[int(key[i],0)] = min(cost[i],dp[int(key[i],0)]) dp[int(key[i],0)] dp int(key[i],0) int key[i] key i 0 min(cost[i],dp[int(key[i],0)]) min cost[i] cost i dp[int(key[i],0)] dp int(key[i],0) int key[i] key i 0 for i in range(2**n):
    if dp[i] != inf:
        for j in range(m):
            k = int(key[j], 0)
            tar = k | i
            dp[tar] = min(dp[tar], dp[i] + cost[j]) i range(2**n) range 2**n 2 n if dp[i] != inf:
        for j in range(m):
            k = int(key[j], 0)
            tar = k | i
            dp[tar] = min(dp[tar], dp[i] + cost[j]) dp[i] != inf dp[i] dp i inf for j in range(m):
            k = int(key[j], 0)
            tar = k | i
            dp[tar] = min(dp[tar], dp[i] + cost[j]) j range(m) range m k = int(key[j], 0) k int(key[j], 0) int key[j] key j 0 tar = k | i tar k | i k i dp[tar] = min(dp[tar], dp[i] + cost[j]) dp[tar] dp tar min(dp[tar], dp[i] + cost[j]) min dp[tar] dp tar dp[i] + cost[j] dp[i] dp i cost[j] cost j if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1]) dp[-1] == inf dp[-1] dp -1 inf print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 cost = [] [] cost inf = int(1e9) int(1e9) inf a,b = map(int,input().split()) map(int,input().split()) a tar = k | i k | i tar m = map(int,input().split()) map(int,input().split()) m c = list(map(int,input().split())) list(map(int,input().split())) c cnt = 0 0 cnt b = map(int,input().split()) map(int,input().split()) b k = int(key[j], 0) int(key[j], 0) k cnt += 2**(n-j) 2**(n-j) cnt key = [] [] key dp = [inf]*(2**n) [inf]*(2**n) dp n,m = map(int,input().split()) map(int,input().split()) n
n,m = map(int,input().split())
cost = []
key = []
inf = int(1e9)
for i in range(m):
    a,b = map(int,input().split())
    c = list(map(int,input().split()))
    cost.append(a)
    cnt = 0
    for j in range(1,n+1):
        if j in c:
           cnt += 2**(n-j)
    key.append(bin(cnt))
dp = [inf]*(2**n)
for i in range(m):
    dp[int(key[i],0)] = min(cost[i],dp[int(key[i],0)])
for i in range(2**n):
    if dp[i] != inf:
        for j in range(m):
            k = int(key[j], 0)
            tar = k | i
            dp[tar] = min(dp[tar], dp[i] + cost[j])
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])



