#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    g = []
    for _ in range(m):
        a,_ = LI()
        c = LI()
        b = 0
        for i in c:
            b |= 1<<(i-1)
        g.append((b,a))
    B = 1<<n
    dp = [float("inf")]*B
    dp[0] = 0
    for b in range(B):
        for i,v in g:
            nb = b|i
            nd = dp[b]+v
            if nd < dp[nb]:
                dp[nb] = nd
    ans = dp[-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve() from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys sys import math math import bisect bisect int(x) for x in sys.stdin.buffer.readline().split() for x in sys.stdin.buffer.readline().split() x sys.stdin.buffer.readline().split() sys.stdin.buffer.readline().split sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline split for x in sys.stdin.buffer.readline().split() int(x) int x def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] LI def I(): return int(sys.stdin.buffer.readline()) I list(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() list(x) list x def LS():return [list(x) for x in sys.stdin.readline().split()] LS def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res S res = list(sys.stdin.readline()) res list(sys.stdin.readline()) list sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline if res[-1] == "\n":
        return res[:-1]
     res[-1] == "\n" res[-1] res -1 "\n" return res[:-1] res[:-1] res :-1 -1 return res res def IR(n):
    return [I() for i in range(n)] IR I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I return [I() for i in range(n)] [I() for i in range(n)] n n def LIR(n):
    return [LI() for i in range(n)] LIR LI() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LI() LI return [LI() for i in range(n)] [LI() for i in range(n)] n n def SR(n):
    return [S() for i in range(n)] SR S() for i in range(n) for i in range(n) i range(n) range n for i in range(n) S() S return [S() for i in range(n)] [S() for i in range(n)] n n def LSR(n):
    return [LS() for i in range(n)] LSR LS() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LS() LS return [LS() for i in range(n)] [LS() for i in range(n)] n n sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 mod = 1000000007 mod 1000000007 def solve():
    n,m = LI()
    g = []
    for _ in range(m):
        a,_ = LI()
        c = LI()
        b = 0
        for i in c:
            b |= 1<<(i-1)
        g.append((b,a))
    B = 1<<n
    dp = [float("inf")]*B
    dp[0] = 0
    for b in range(B):
        for i,v in g:
            nb = b|i
            nd = dp[b]+v
            if nd < dp[nb]:
                dp[nb] = nd
    ans = dp[-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return

#Solve solve n,m = LI() n LI() LI m g = [] g [] for _ in range(m):
        a,_ = LI()
        c = LI()
        b = 0
        for i in c:
            b |= 1<<(i-1)
        g.append((b,a))
     _ range(m) range m a,_ = LI() a LI() LI _ c = LI() c LI() LI b = 0 b 0 for i in c:
            b |= 1<<(i-1)
         i c b |= 1<<(i-1) b 1<<(i-1) 1 i-1 i 1 g.append((b,a)) g.append g append (b,a) b a B = 1<<n B 1<<n 1 n dp = [float("inf")]*B dp [float("inf")]*B [float("inf")] float("inf") float "inf" B dp[0] = 0 dp[0] dp 0 0 for b in range(B):
        for i,v in g:
            nb = b|i
            nd = dp[b]+v
            if nd < dp[nb]:
                dp[nb] = nd
     b range(B) range B for i,v in g:
            nb = b|i
            nd = dp[b]+v
            if nd < dp[nb]:
                dp[nb] = nd
     i v g nb = b|i nb b|i b i nd = dp[b]+v nd dp[b]+v dp[b] dp b v if nd < dp[nb]:
                dp[nb] = nd
     nd < dp[nb] nd dp[nb] dp nb dp[nb] = nd dp[nb] dp nb nd ans = dp[-1] ans dp[-1] dp -1 if ans == float("inf"):
        print(-1)
    else:
        print(ans)
     ans == float("inf") ans float("inf") float "inf" print(-1) print -1 print(ans) print ans return if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def I(): return int(sys.stdin.buffer.readline()) def I(): return int(sys.stdin.buffer.readline()) I def LS():return [list(x) for x in sys.stdin.readline().split()] def LS():return [list(x) for x in sys.stdin.readline().split()] LS def LSR(n):
    return [LS() for i in range(n)] def LSR(n):
    return [LS() for i in range(n)] LSR def solve():
    n,m = LI()
    g = []
    for _ in range(m):
        a,_ = LI()
        c = LI()
        b = 0
        for i in c:
            b |= 1<<(i-1)
        g.append((b,a))
    B = 1<<n
    dp = [float("inf")]*B
    dp[0] = 0
    for b in range(B):
        for i,v in g:
            nb = b|i
            nd = dp[b]+v
            if nd < dp[nb]:
                dp[nb] = nd
    ans = dp[-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return

#Solve def solve():
    n,m = LI()
    g = []
    for _ in range(m):
        a,_ = LI()
        c = LI()
        b = 0
        for i in c:
            b |= 1<<(i-1)
        g.append((b,a))
    B = 1<<n
    dp = [float("inf")]*B
    dp[0] = 0
    for b in range(B):
        for i,v in g:
            nb = b|i
            nd = dp[b]+v
            if nd < dp[nb]:
                dp[nb] = nd
    ans = dp[-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return

#Solve solve mod = 1000000007 1000000007 mod def LIR(n):
    return [LI() for i in range(n)] def LIR(n):
    return [LI() for i in range(n)] LIR def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res S def IR(n):
    return [I() for i in range(n)] def IR(n):
    return [I() for i in range(n)] IR def SR(n):
    return [S() for i in range(n)] def SR(n):
    return [S() for i in range(n)] SR def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] LI
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    g = []
    for _ in range(m):
        a,_ = LI()
        c = LI()
        b = 0
        for i in c:
            b |= 1<<(i-1)
        g.append((b,a))
    B = 1<<n
    dp = [float("inf")]*B
    dp[0] = 0
    for b in range(B):
        for i,v in g:
            nb = b|i
            nd = dp[b]+v
            if nd < dp[nb]:
                dp[nb] = nd
    ans = dp[-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()
