# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
a = []
b = []
c = []

for i in range(m):
    a_, b_ = map(int, input().split())
    c_ = list(map(int, input().split()))
    a.append(a_)
    b.append(b_)
    val = 0
    for _c_ in c_:
        val += 2 ** (_c_ -1)
    c.append(val)

max_m = 2**n

dp = [[float('inf')] * max_m for _ in range(m+1)]
dp[0][0]=0

# print(c)

for i in range(1, m+1):
    for combi in range(max_m):
        # print(c[i-1])
        combi_diff = 0
        combi_diff = combi & ~c[i-1]
        dp[i][combi] = min(dp[i-1][combi], dp[i-1][combi_diff] + a[i-1])

if dp[-1][-1] == float('inf'):
    print(-1)
else:
    print(dp[-1][-1])
 import sys sys from collections import defaultdict, deque from heapq import heappush, heappop import math math import bisect bisect input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a = [] a [] b = [] b [] c = [] c [] for i in range(m):
    a_, b_ = map(int, input().split())
    c_ = list(map(int, input().split()))
    a.append(a_)
    b.append(b_)
    val = 0
    for _c_ in c_:
        val += 2 ** (_c_ -1)
    c.append(val) 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 a.append(a_) a.append a append a_ b.append(b_) b.append b append b_ val = 0 val 0 for _c_ in c_:
        val += 2 ** (_c_ -1)
     _c_ c_ val += 2 ** (_c_ -1) val 2 ** (_c_ -1) 2 _c_ -1 _c_ 1 c.append(val) c.append c append val max_m = 2**n max_m 2**n 2 n [float('inf')] * max_m for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [float('inf')] * max_m [float('inf')] float('inf') float 'inf' max_m dp = [[float('inf')] * max_m for _ in range(m+1)] dp [[float('inf')] * max_m for _ in range(m+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(1, m+1):
    for combi in range(max_m):
        # print(c[i-1])
        combi_diff = 0
        combi_diff = combi & ~c[i-1]
        dp[i][combi] = min(dp[i-1][combi], dp[i-1][combi_diff] + a[i-1]) i range(1, m+1) range 1 m+1 m 1 for combi in range(max_m):
        # print(c[i-1])
        combi_diff = 0
        combi_diff = combi & ~c[i-1]
        dp[i][combi] = min(dp[i-1][combi], dp[i-1][combi_diff] + a[i-1]) combi range(max_m) range max_m combi_diff = 0 combi_diff 0 combi_diff = combi & ~c[i-1] combi_diff combi & ~c[i-1] combi ~c[i-1] c[i-1] c i-1 i 1 dp[i][combi] = min(dp[i-1][combi], dp[i-1][combi_diff] + a[i-1]) dp[i][combi] [i] dp i combi min(dp[i-1][combi], dp[i-1][combi_diff] + a[i-1]) min dp[i-1][combi] [i-1] dp i-1 i 1 combi dp[i-1][combi_diff] + a[i-1] dp[i-1][combi_diff] [i-1] dp i-1 i 1 combi_diff a[i-1] a i-1 i 1 if dp[-1][-1] == float('inf'):
    print(-1)
else:
    print(dp[-1][-1]) dp[-1][-1] == float('inf') dp[-1][-1] [-1] dp -1 -1 float('inf') float 'inf' print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 a_, b_ = map(int, input().split()) map(int, input().split()) a_ combi_diff = combi & ~c[i-1] combi & ~c[i-1] combi_diff val += 2 ** (_c_ -1) 2 ** (_c_ -1) val dp = [[float('inf')] * max_m for _ in range(m+1)] [[float('inf')] * max_m for _ in range(m+1)] dp b = [] [] b val = 0 0 val c = [] [] c input = sys.stdin.readline sys.stdin.readline input b_ = map(int, input().split()) map(int, input().split()) b_ n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m max_m = 2**n 2**n max_m combi_diff = 0 0 combi_diff c_ = list(map(int, input().split())) list(map(int, input().split())) c_ a = [] [] a
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
a = []
b = []
c = []

for i in range(m):
    a_, b_ = map(int, input().split())
    c_ = list(map(int, input().split()))
    a.append(a_)
    b.append(b_)
    val = 0
    for _c_ in c_:
        val += 2 ** (_c_ -1)
    c.append(val)

max_m = 2**n

dp = [[float('inf')] * max_m for _ in range(m+1)]
dp[0][0]=0

# print(c)

for i in range(1, m+1):
    for combi in range(max_m):
        # print(c[i-1])
        combi_diff = 0
        combi_diff = combi & ~c[i-1]
        dp[i][combi] = min(dp[i-1][combi], dp[i-1][combi_diff] + a[i-1])

if dp[-1][-1] == float('inf'):
    print(-1)
else:
    print(dp[-1][-1])

