import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M = map(int,(input().split()))
dp = [float("inf")]*(2**N)
dp[0] = 0
for i in range(M):
    a,b = map(int,(input().split()))
    c = list(map(int,(input().split())))
    d = 0
    for j in c:
        d += 2**(j-1)
    for j in range(2**N):
        dp[j|d] = min(dp[j|d],dp[j]+a)

ans = dp[-1]
if ans != float("inf"):
    print(ans)
else:
    print(-1) import bisect bisect import collections collections import functools functools import heapq heapq import math math import sys sys from collections import deque from collections import defaultdict input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 N,M = map(int,(input().split())) N map(int,(input().split())) map int input().split() ().split () input split M dp = [float("inf")]*(2**N) dp [float("inf")]*(2**N) [float("inf")] float("inf") float "inf" 2**N 2 N dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    a,b = map(int,(input().split()))
    c = list(map(int,(input().split())))
    d = 0
    for j in c:
        d += 2**(j-1)
    for j in range(2**N):
        dp[j|d] = min(dp[j|d],dp[j]+a) 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 d = 0 d 0 for j in c:
        d += 2**(j-1)
     j c d += 2**(j-1) d 2**(j-1) 2 j-1 j 1 for j in range(2**N):
        dp[j|d] = min(dp[j|d],dp[j]+a) j range(2**N) range 2**N 2 N dp[j|d] = min(dp[j|d],dp[j]+a) dp[j|d] dp j|d j d min(dp[j|d],dp[j]+a) min dp[j|d] dp j|d j d dp[j]+a dp[j] dp j a ans = dp[-1] ans dp[-1] dp -1 if ans != float("inf"):
    print(ans)
else:
    print(-1) ans != float("inf") ans float("inf") float "inf" print(ans) print ans print(-1) print -1 b = map(int,(input().split())) map(int,(input().split())) b M = map(int,(input().split())) map(int,(input().split())) M N,M = map(int,(input().split())) map(int,(input().split())) N dp = [float("inf")]*(2**N) [float("inf")]*(2**N) dp input = sys.stdin.readline sys.stdin.readline input a,b = map(int,(input().split())) map(int,(input().split())) a c = list(map(int,(input().split()))) list(map(int,(input().split()))) c d += 2**(j-1) 2**(j-1) d MOD = 10**9+7 10**9+7 MOD ans = dp[-1] dp[-1] ans d = 0 0 d
import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M = map(int,(input().split()))
dp = [float("inf")]*(2**N)
dp[0] = 0
for i in range(M):
    a,b = map(int,(input().split()))
    c = list(map(int,(input().split())))
    d = 0
    for j in c:
        d += 2**(j-1)
    for j in range(2**N):
        dp[j|d] = min(dp[j|d],dp[j]+a)

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