from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    inf=10**9
    n,m=MI()
    kk=[]
    aa=[]
    for _ in range(m):
        k=0
        a,b=MI()
        aa.append(a)
        cc=LI1()
        for c in cc:k|=1<<c
        kk.append(k)
    dp=[inf]*(1<<n)
    dp[0]=0
    for bit in range(1<<n):
        pre=dp[bit]
        if pre==inf:continue
        for a,k in zip(aa,kk):
            nb=bit|k
            dp[nb]=min(dp[nb],pre+a)
    ans=dp[-1]
    if ans==inf:print(-1)
    else:print(ans)

main() from itertools import permutations import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 from bisect import * from collections import * from heapq import * def II(): return int(sys.stdin.readline()) II def MI(): return map(int, sys.stdin.readline().split()) MI def LI(): return list(map(int, sys.stdin.readline().split())) LI def SI(): return sys.stdin.readline()[:-1] SI LI() for _ in range(rows_number) for _ in range(rows_number) _ range(rows_number) range rows_number for _ in range(rows_number) LI() LI def LLI(rows_number): return [LI() for _ in range(rows_number)] LLI rows_number rows_number int1 = lambda x: int(x) - 1 int1 lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x def MI1(): return map(int1, sys.stdin.readline().split()) MI1 def LI1(): return list(map(int1, sys.stdin.readline().split())) LI1 p2D = lambda x: print(*x, sep="\n") p2D lambda x: print(*x, sep="\n") print(*x, sep="\n") print *x x sep="\n" sep "\n" x dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] dij [(1, 0), (0, 1), (-1, 0), (0, -1)] (1, 0) 1 0 (0, 1) 0 1 (-1, 0) -1 0 (0, -1) 0 -1 def main():
    inf=10**9
    n,m=MI()
    kk=[]
    aa=[]
    for _ in range(m):
        k=0
        a,b=MI()
        aa.append(a)
        cc=LI1()
        for c in cc:k|=1<<c
        kk.append(k)
    dp=[inf]*(1<<n)
    dp[0]=0
    for bit in range(1<<n):
        pre=dp[bit]
        if pre==inf:continue
        for a,k in zip(aa,kk):
            nb=bit|k
            dp[nb]=min(dp[nb],pre+a)
    ans=dp[-1]
    if ans==inf:print(-1)
    else:print(ans) main inf=10**9 inf 10**9 10 9 n,m=MI() n MI() MI m kk=[] kk [] aa=[] aa [] for _ in range(m):
        k=0
        a,b=MI()
        aa.append(a)
        cc=LI1()
        for c in cc:k|=1<<c
        kk.append(k)
     _ range(m) range m k=0 k 0 a,b=MI() a MI() MI b aa.append(a) aa.append aa append a cc=LI1() cc LI1() LI1 for c in cc:k|=1<<c
         c cc kk.append(k) kk.append kk append k dp=[inf]*(1<<n) dp [inf]*(1<<n) [inf] inf 1<<n 1 n dp[0]=0 dp[0] dp 0 0 for bit in range(1<<n):
        pre=dp[bit]
        if pre==inf:continue
        for a,k in zip(aa,kk):
            nb=bit|k
            dp[nb]=min(dp[nb],pre+a)
     bit range(1<<n) range 1<<n 1 n pre=dp[bit] pre dp[bit] dp bit if pre==inf:continue
         pre==inf pre inf for a,k in zip(aa,kk):
            nb=bit|k
            dp[nb]=min(dp[nb],pre+a)
     a k zip(aa,kk) zip aa kk nb=bit|k nb bit|k bit k dp[nb]=min(dp[nb],pre+a) dp[nb] dp nb min(dp[nb],pre+a) min dp[nb] dp nb pre+a pre a ans=dp[-1] ans dp[-1] dp -1 if ans==inf:print(-1)
    else:print(ans) ans==inf ans inf main() main def II(): return int(sys.stdin.readline()) def II(): return int(sys.stdin.readline()) II def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI(rows_number): return [LI() for _ in range(rows_number)] LLI def main():
    inf=10**9
    n,m=MI()
    kk=[]
    aa=[]
    for _ in range(m):
        k=0
        a,b=MI()
        aa.append(a)
        cc=LI1()
        for c in cc:k|=1<<c
        kk.append(k)
    dp=[inf]*(1<<n)
    dp[0]=0
    for bit in range(1<<n):
        pre=dp[bit]
        if pre==inf:continue
        for a,k in zip(aa,kk):
            nb=bit|k
            dp[nb]=min(dp[nb],pre+a)
    ans=dp[-1]
    if ans==inf:print(-1)
    else:print(ans) def main():
    inf=10**9
    n,m=MI()
    kk=[]
    aa=[]
    for _ in range(m):
        k=0
        a,b=MI()
        aa.append(a)
        cc=LI1()
        for c in cc:k|=1<<c
        kk.append(k)
    dp=[inf]*(1<<n)
    dp[0]=0
    for bit in range(1<<n):
        pre=dp[bit]
        if pre==inf:continue
        for a,k in zip(aa,kk):
            nb=bit|k
            dp[nb]=min(dp[nb],pre+a)
    ans=dp[-1]
    if ans==inf:print(-1)
    else:print(ans) main def LI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) LI def MI1(): return map(int1, sys.stdin.readline().split()) def MI1(): return map(int1, sys.stdin.readline().split()) MI1 def LI1(): return list(map(int1, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) LI1 dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] [(1, 0), (0, 1), (-1, 0), (0, -1)] dij def SI(): return sys.stdin.readline()[:-1] def SI(): return sys.stdin.readline()[:-1] SI p2D = lambda x: print(*x, sep="\n") lambda x: print(*x, sep="\n") p2D def MI(): return map(int, sys.stdin.readline().split()) def MI(): return map(int, sys.stdin.readline().split()) MI int1 = lambda x: int(x) - 1 lambda x: int(x) - 1 int1
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    inf=10**9
    n,m=MI()
    kk=[]
    aa=[]
    for _ in range(m):
        k=0
        a,b=MI()
        aa.append(a)
        cc=LI1()
        for c in cc:k|=1<<c
        kk.append(k)
    dp=[inf]*(1<<n)
    dp[0]=0
    for bit in range(1<<n):
        pre=dp[bit]
        if pre==inf:continue
        for a,k in zip(aa,kk):
            nb=bit|k
            dp[nb]=min(dp[nb],pre+a)
    ans=dp[-1]
    if ans==inf:print(-1)
    else:print(ans)

main()
