#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n,m=MI()
data=[]
for i in range(m):
    a,b=MI()
    c=LI()
    u=0
    for x in c:
        u+=2**(x-1)
    data.append([a,u])
data.sort()
#print(data)
dp=[[inf]*(2**n) for i in range(m+1)]
dp[0]=[inf]*(2**n)
dp[0][0]=0
#print(dp)
for i in range(m):
    for j in range(2**n):
        dp[i+1][j|data[i][1]]=min(dp[i+1][j|data[i][1]],dp[i][j|data[i][1]],dp[i][j]+data[i][0])
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        #print(i+1,j|data[i][1],dp[i][j|data[i][1]],dp[i][j]+data[i][0])
    #print()
#print(dp)
if dp[-1][-1]>=inf:
    print(-1)
else:
    print(dp[-1][-1]) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) I def MI(): return map(int, input().split()) MI def LI(): return list(map(int, input().split())) LI int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input def LI2(): return [int(input()) for i in range(n)] LI2 [LI()]for i in range(n) for i in range(n) i range(n) range n for i in range(n) [LI()] LI() LI def MXI(): return [[LI()]for i in range(n)] MXI def SI(): return input().rstrip() SI def printns(x): print('\n'.join(x)) printns x x def printni(x): print('\n'.join(list(map(str,x)))) printni x x inf = 10**17 inf 10**17 10 17 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 n,m=MI() n MI() MI m data=[] data [] for i in range(m):
    a,b=MI()
    c=LI()
    u=0
    for x in c:
        u+=2**(x-1)
    data.append([a,u]) i range(m) range m a,b=MI() a MI() MI b c=LI() c LI() LI u=0 u 0 for x in c:
        u+=2**(x-1)
     x c u+=2**(x-1) u 2**(x-1) 2 x-1 x 1 data.append([a,u]) data.append data append [a,u] a u data.sort() data.sort data sort [inf]*(2**n) for i in range(m+1) for i in range(m+1) i range(m+1) range m+1 m 1 for i in range(m+1) [inf]*(2**n) [inf] inf 2**n 2 n dp=[[inf]*(2**n) for i in range(m+1)] dp [[inf]*(2**n) for i in range(m+1)] dp[0]=[inf]*(2**n) dp[0] dp 0 [inf]*(2**n) [inf] inf 2**n 2 n dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    for j in range(2**n):
        dp[i+1][j|data[i][1]]=min(dp[i+1][j|data[i][1]],dp[i][j|data[i][1]],dp[i][j]+data[i][0])
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        #print(i+1,j|data[i][1],dp[i][j|data[i][1]],dp[i][j]+data[i][0])
    #print()
#print(dp) i range(m) range m for j in range(2**n):
        dp[i+1][j|data[i][1]]=min(dp[i+1][j|data[i][1]],dp[i][j|data[i][1]],dp[i][j]+data[i][0])
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        #print(i+1,j|data[i][1],dp[i][j|data[i][1]],dp[i][j]+data[i][0])
    #print()
#print(dp) j range(2**n) range 2**n 2 n dp[i+1][j|data[i][1]]=min(dp[i+1][j|data[i][1]],dp[i][j|data[i][1]],dp[i][j]+data[i][0]) dp[i+1][j|data[i][1]] [i+1] dp i+1 i 1 j|data[i][1] j data[i][1] [i] data i 1 min(dp[i+1][j|data[i][1]],dp[i][j|data[i][1]],dp[i][j]+data[i][0]) min dp[i+1][j|data[i][1]] [i+1] dp i+1 i 1 j|data[i][1] j data[i][1] [i] data i 1 dp[i][j|data[i][1]] [i] dp i j|data[i][1] j data[i][1] [i] data i 1 dp[i][j]+data[i][0] dp[i][j] [i] dp i j data[i][0] [i] data i 0 dp[i+1][j]=min(dp[i][j],dp[i+1][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i][j],dp[i+1][j]) min dp[i][j] [i] dp i j dp[i+1][j] [i+1] dp i+1 i 1 j if dp[-1][-1]>=inf:
    print(-1)
else:
    print(dp[-1][-1]) dp[-1][-1]>=inf dp[-1][-1] [-1] dp -1 -1 inf print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 a,b=MI() MI() a def LI2(): return [int(input()) for i in range(n)] def LI2(): return [int(input()) for i in range(n)] LI2 m=MI() MI() m inf = 10**17 10**17 inf c=LI() LI() c input = sys.stdin.readline sys.stdin.readline input data=[] [] data u=0 0 u def MXI(): return [[LI()]for i in range(n)] def MXI(): return [[LI()]for i in range(n)] MXI u+=2**(x-1) 2**(x-1) u def SI(): return input().rstrip() def SI(): return input().rstrip() SI def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI n,m=MI() MI() n def printni(x): print('\n'.join(list(map(str,x)))) def printni(x): print('\n'.join(list(map(str,x)))) printni def MI(): return map(int, input().split()) def MI(): return map(int, input().split()) MI b=MI() MI() b def printns(x): print('\n'.join(x)) def printns(x): print('\n'.join(x)) printns mod = 10**9 + 7 10**9 + 7 mod def I(): return int(input()) def I(): return int(input()) I dp=[[inf]*(2**n) for i in range(m+1)] [[inf]*(2**n) for i in range(m+1)] dp
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n,m=MI()
data=[]
for i in range(m):
    a,b=MI()
    c=LI()
    u=0
    for x in c:
        u+=2**(x-1)
    data.append([a,u])
data.sort()
#print(data)
dp=[[inf]*(2**n) for i in range(m+1)]
dp[0]=[inf]*(2**n)
dp[0][0]=0
#print(dp)
for i in range(m):
    for j in range(2**n):
        dp[i+1][j|data[i][1]]=min(dp[i+1][j|data[i][1]],dp[i][j|data[i][1]],dp[i][j]+data[i][0])
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        #print(i+1,j|data[i][1],dp[i][j|data[i][1]],dp[i][j]+data[i][0])
    #print()
#print(dp)
if dp[-1][-1]>=inf:
    print(-1)
else:
    print(dp[-1][-1])