#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    # 1-index
    k = [None]
    for _ in range(m):
        a, _ = mi()
        k.append([a, lmi()])

    d = 2 ** n
    dp = [[0] * d for _ in range(m + 1)]
    for j in range(1, d):
        dp[0][j] = inf
    for j in range(1, d):
        for i in range(1, m + 1):
            cost = k[i][0]
            able_to_open = k[i][1]
            mask = 0b0
            for num in able_to_open:
                mask |= (1 << (num - 1))
            # print(bin(mask))
            mask = ~mask
            # print(bin(mask))
            j_prime = j & mask
            dp[i][j] = min(dp[i-1][j], dp[i-1][j_prime] + cost)
    # print(dp)
    print(dp[m][d-1]) if dp[m][d-1] != inf else print(-1)

if __name__ == "__main__":
    main() import sys sys def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    # 1-index
    k = [None]
    for _ in range(m):
        a, _ = mi()
        k.append([a, lmi()])

    d = 2 ** n
    dp = [[0] * d for _ in range(m + 1)]
    for j in range(1, d):
        dp[0][j] = inf
    for j in range(1, d):
        for i in range(1, m + 1):
            cost = k[i][0]
            able_to_open = k[i][1]
            mask = 0b0
            for num in able_to_open:
                mask |= (1 << (num - 1))
            # print(bin(mask))
            mask = ~mask
            # print(bin(mask))
            j_prime = j & mask
            dp[i][j] = min(dp[i-1][j], dp[i-1][j_prime] + cost)
    # print(dp)
    print(dp[m][d-1]) if dp[m][d-1] != inf else print(-1) main mod = 1000000007 mod 1000000007 inf = float('inf') inf float('inf') float 'inf' sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 def input(): return sys.stdin.readline().rstrip()
     input def ii():  return int(input())
     ii def mi():  return map(int, input().split())
     mi def mi_0(): return map(lambda x: int(x)-1, input().split())
     mi_0 def lmi(): return list(map(int, input().split()))
     lmi def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
     lmi_0 def li():  return list(input())
    
    
     li n, m = mi() n mi() mi m k = [None] k [None] None for _ in range(m):
        a, _ = mi()
        k.append([a, lmi()])

     _ range(m) range m a, _ = mi() a mi() mi _ k.append([a, lmi()]) k.append k append [a, lmi()] a lmi() lmi d = 2 ** n d 2 ** n 2 n [0] * d for _ in range(m + 1) for _ in range(m + 1) _ range(m + 1) range m + 1 m 1 for _ in range(m + 1) [0] * d [0] 0 d dp = [[0] * d for _ in range(m + 1)] dp [[0] * d for _ in range(m + 1)] for j in range(1, d):
        dp[0][j] = inf
     j range(1, d) range 1 d dp[0][j] = inf dp[0][j] [0] dp 0 j inf for j in range(1, d):
        for i in range(1, m + 1):
            cost = k[i][0]
            able_to_open = k[i][1]
            mask = 0b0
            for num in able_to_open:
                mask |= (1 << (num - 1))
            # print(bin(mask))
            mask = ~mask
            # print(bin(mask))
            j_prime = j & mask
            dp[i][j] = min(dp[i-1][j], dp[i-1][j_prime] + cost)
    # print(dp)
     j range(1, d) range 1 d for i in range(1, m + 1):
            cost = k[i][0]
            able_to_open = k[i][1]
            mask = 0b0
            for num in able_to_open:
                mask |= (1 << (num - 1))
            # print(bin(mask))
            mask = ~mask
            # print(bin(mask))
            j_prime = j & mask
            dp[i][j] = min(dp[i-1][j], dp[i-1][j_prime] + cost)
    # print(dp)
     i range(1, m + 1) range 1 m + 1 m 1 cost = k[i][0] cost k[i][0] [i] k i 0 able_to_open = k[i][1] able_to_open k[i][1] [i] k i 1 mask = 0b0 mask 0b0 for num in able_to_open:
                mask |= (1 << (num - 1))
            # print(bin(mask))
             num able_to_open mask |= (1 << (num - 1)) mask 1 << (num - 1) 1 num - 1 num 1 mask = ~mask mask ~mask mask j_prime = j & mask j_prime j & mask j mask dp[i][j] = min(dp[i-1][j], dp[i-1][j_prime] + cost) dp[i][j] [i] dp i j min(dp[i-1][j], dp[i-1][j_prime] + cost) min dp[i-1][j] [i-1] dp i-1 i 1 j dp[i-1][j_prime] + cost dp[i-1][j_prime] [i-1] dp i-1 i 1 j_prime cost print(dp[m][d-1]) if dp[m][d-1] != inf else print(-1) dp[m][d-1] != inf dp[m][d-1] [m] dp m d-1 d 1 inf print(dp[m][d-1]) print dp[m][d-1] [m] dp m d-1 d 1 print(-1) print -1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    # 1-index
    k = [None]
    for _ in range(m):
        a, _ = mi()
        k.append([a, lmi()])

    d = 2 ** n
    dp = [[0] * d for _ in range(m + 1)]
    for j in range(1, d):
        dp[0][j] = inf
    for j in range(1, d):
        for i in range(1, m + 1):
            cost = k[i][0]
            able_to_open = k[i][1]
            mask = 0b0
            for num in able_to_open:
                mask |= (1 << (num - 1))
            # print(bin(mask))
            mask = ~mask
            # print(bin(mask))
            j_prime = j & mask
            dp[i][j] = min(dp[i-1][j], dp[i-1][j_prime] + cost)
    # print(dp)
    print(dp[m][d-1]) if dp[m][d-1] != inf else print(-1) def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    # 1-index
    k = [None]
    for _ in range(m):
        a, _ = mi()
        k.append([a, lmi()])

    d = 2 ** n
    dp = [[0] * d for _ in range(m + 1)]
    for j in range(1, d):
        dp[0][j] = inf
    for j in range(1, d):
        for i in range(1, m + 1):
            cost = k[i][0]
            able_to_open = k[i][1]
            mask = 0b0
            for num in able_to_open:
                mask |= (1 << (num - 1))
            # print(bin(mask))
            mask = ~mask
            # print(bin(mask))
            j_prime = j & mask
            dp[i][j] = min(dp[i-1][j], dp[i-1][j_prime] + cost)
    # print(dp)
    print(dp[m][d-1]) if dp[m][d-1] != inf else print(-1) main
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    # 1-index
    k = [None]
    for _ in range(m):
        a, _ = mi()
        k.append([a, lmi()])

    d = 2 ** n
    dp = [[0] * d for _ in range(m + 1)]
    for j in range(1, d):
        dp[0][j] = inf
    for j in range(1, d):
        for i in range(1, m + 1):
            cost = k[i][0]
            able_to_open = k[i][1]
            mask = 0b0
            for num in able_to_open:
                mask |= (1 << (num - 1))
            # print(bin(mask))
            mask = ~mask
            # print(bin(mask))
            j_prime = j & mask
            dp[i][j] = min(dp[i-1][j], dp[i-1][j_prime] + cost)
    # print(dp)
    print(dp[m][d-1]) if dp[m][d-1] != inf else print(-1)

if __name__ == "__main__":
    main()