from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
wv = []
for i in range(m):
    a,b = inpl()
    cnt = 0
    c = inpl()
    for i in c:
        cnt += 1<<(i-1)
    wv.append((a,cnt))
dp = [INF for _ in range(1<<n)]
dp[0] = 0

for i in range(m):
    v,w = wv[i]
    for j in range(1<<n):
        dp[j|w] = min(dp[j|w], dp[j] + v)
print(dp[-1] if dp[-1] != INF else -1) from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions sys bisect math itertools fractions from decimal import Decimal sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 INF = float('inf') INF float('inf') float 'inf' def inp(): return int(sys.stdin.readline()) inp def inpl(): return list(map(int, sys.stdin.readline().split())) inpl n,m = inpl() n inpl() inpl m wv = [] wv [] for i in range(m):
    a,b = inpl()
    cnt = 0
    c = inpl()
    for i in c:
        cnt += 1<<(i-1)
    wv.append((a,cnt)) i range(m) range m a,b = inpl() a inpl() inpl b cnt = 0 cnt 0 c = inpl() c inpl() inpl for i in c:
        cnt += 1<<(i-1)
     i c cnt += 1<<(i-1) cnt 1<<(i-1) 1 i-1 i 1 wv.append((a,cnt)) wv.append wv append (a,cnt) a cnt INF for _ in range(1<<n) for _ in range(1<<n) _ range(1<<n) range 1<<n 1 n for _ in range(1<<n) INF dp = [INF for _ in range(1<<n)] dp [INF for _ in range(1<<n)] dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    v,w = wv[i]
    for j in range(1<<n):
        dp[j|w] = min(dp[j|w], dp[j] + v) i range(m) range m v,w = wv[i] v wv[i] wv i w for j in range(1<<n):
        dp[j|w] = min(dp[j|w], dp[j] + v) j range(1<<n) range 1<<n 1 n dp[j|w] = min(dp[j|w], dp[j] + v) dp[j|w] dp j|w j w min(dp[j|w], dp[j] + v) min dp[j|w] dp j|w j w dp[j] + v dp[j] dp j v print(dp[-1] if dp[-1] != INF else -1) print dp[-1] if dp[-1] != INF else -1 dp[-1] != INF dp[-1] dp -1 INF dp[-1] dp -1 -1 INF = float('inf') float('inf') INF cnt += 1<<(i-1) 1<<(i-1) cnt def inp(): return int(sys.stdin.readline()) def inp(): return int(sys.stdin.readline()) inp w = wv[i] wv[i] w c = inpl() inpl() c wv = [] [] wv a,b = inpl() inpl() a mod = 10**9+7 10**9+7 mod dp = [INF for _ in range(1<<n)] [INF for _ in range(1<<n)] dp b = inpl() inpl() b cnt = 0 0 cnt def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl(): return list(map(int, sys.stdin.readline().split())) inpl n,m = inpl() inpl() n m = inpl() inpl() m v,w = wv[i] wv[i] v
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
wv = []
for i in range(m):
    a,b = inpl()
    cnt = 0
    c = inpl()
    for i in c:
        cnt += 1<<(i-1)
    wv.append((a,cnt))
dp = [INF for _ in range(1<<n)]
dp[0] = 0

for i in range(m):
    v,w = wv[i]
    for j in range(1<<n):
        dp[j|w] = min(dp[j|w], dp[j] + v)
print(dp[-1] if dp[-1] != INF else -1)