import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m = ns()
    d = []
    for _ in range(m):
        ai, bi = ns()
        ci = na()
        d.append([ai, bi, ci])

    # bit DP
    # dp[i] = iの各bitが1である番目の宝箱を開けられる状態となれる最小コスト
    dp = [INF for _ in range(2 ** n)]
    dp[0] = 0

    for ai, bi, ci in d:
        getkey = 0
        for cii in ci:
            cii -= 1
            getkey += 1 << cii

        for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

    tmp = dp[2 ** n - 1]
    print(tmp if tmp != INF else -1)


if __name__ == '__main__':
    main() import sys sys import re re import math math import collections collections import decimal decimal import bisect bisect import itertools itertools import fractions fractions import functools functools import copy copy import heapq heapq import decimal decimal import statistics statistics import queue queue sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 10 ** 16 INF 10 ** 16 10 16 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 ni = lambda: int(sys.stdin.readline()) ni lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline ns = lambda: map(int, sys.stdin.readline().split()) ns lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split na = lambda: list(map(int, sys.stdin.readline().split())) na lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def main():
    n, m = ns()
    d = []
    for _ in range(m):
        ai, bi = ns()
        ci = na()
        d.append([ai, bi, ci])

    # bit DP
    # dp[i] = iの各bitが1である番目の宝箱を開けられる状態となれる最小コスト
    dp = [INF for _ in range(2 ** n)]
    dp[0] = 0

    for ai, bi, ci in d:
        getkey = 0
        for cii in ci:
            cii -= 1
            getkey += 1 << cii

        for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

    tmp = dp[2 ** n - 1]
    print(tmp if tmp != INF else -1) main n, m = ns() n ns() ns m d = [] d [] for _ in range(m):
        ai, bi = ns()
        ci = na()
        d.append([ai, bi, ci])

    # bit DP
    # dp[i] = iの各bitが1である番目の宝箱を開けられる状態となれる最小コスト
     _ range(m) range m ai, bi = ns() ai ns() ns bi ci = na() ci na() na d.append([ai, bi, ci]) d.append d append [ai, bi, ci] ai bi ci INF for _ in range(2 ** n) for _ in range(2 ** n) _ range(2 ** n) range 2 ** n 2 n for _ in range(2 ** n) INF dp = [INF for _ in range(2 ** n)] dp [INF for _ in range(2 ** n)] dp[0] = 0 dp[0] dp 0 0 for ai, bi, ci in d:
        getkey = 0
        for cii in ci:
            cii -= 1
            getkey += 1 << cii

        for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

     ai bi ci d getkey = 0 getkey 0 for cii in ci:
            cii -= 1
            getkey += 1 << cii

         cii ci cii -= 1 cii 1 getkey += 1 << cii getkey 1 << cii 1 cii for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

     i range(2 ** n) range 2 ** n 2 n dp[i | getkey] = min(dp[i | getkey], dp[i] + ai) dp[i | getkey] dp i | getkey i getkey min(dp[i | getkey], dp[i] + ai) min dp[i | getkey] dp i | getkey i getkey dp[i] + ai dp[i] dp i ai tmp = dp[2 ** n - 1] tmp dp[2 ** n - 1] dp 2 ** n - 1 2 ** n 2 n 1 print(tmp if tmp != INF else -1) print tmp if tmp != INF else -1 tmp != INF tmp INF tmp -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n, m = ns()
    d = []
    for _ in range(m):
        ai, bi = ns()
        ci = na()
        d.append([ai, bi, ci])

    # bit DP
    # dp[i] = iの各bitが1である番目の宝箱を開けられる状態となれる最小コスト
    dp = [INF for _ in range(2 ** n)]
    dp[0] = 0

    for ai, bi, ci in d:
        getkey = 0
        for cii in ci:
            cii -= 1
            getkey += 1 << cii

        for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

    tmp = dp[2 ** n - 1]
    print(tmp if tmp != INF else -1) def main():
    n, m = ns()
    d = []
    for _ in range(m):
        ai, bi = ns()
        ci = na()
        d.append([ai, bi, ci])

    # bit DP
    # dp[i] = iの各bitが1である番目の宝箱を開けられる状態となれる最小コスト
    dp = [INF for _ in range(2 ** n)]
    dp[0] = 0

    for ai, bi, ci in d:
        getkey = 0
        for cii in ci:
            cii -= 1
            getkey += 1 << cii

        for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

    tmp = dp[2 ** n - 1]
    print(tmp if tmp != INF else -1) main INF = 10 ** 16 10 ** 16 INF na = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) na ni = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ni MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD ns = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) ns
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m = ns()
    d = []
    for _ in range(m):
        ai, bi = ns()
        ci = na()
        d.append([ai, bi, ci])

    # bit DP
    # dp[i] = iの各bitが1である番目の宝箱を開けられる状態となれる最小コスト
    dp = [INF for _ in range(2 ** n)]
    dp[0] = 0

    for ai, bi, ci in d:
        getkey = 0
        for cii in ci:
            cii -= 1
            getkey += 1 << cii

        for i in range(2 ** n):
            dp[i | getkey] = min(dp[i | getkey], dp[i] + ai)

    tmp = dp[2 ** n - 1]
    print(tmp if tmp != INF else -1)


if __name__ == '__main__':
    main()
