import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    n, m = map(int, input().split())
    key = []  # 集合S，コスト
    for i in range(m):
        a, b = map(int, input().split())
        s = 0
        C = list(map(int, input().split()))
        for j in range(b):
            C[j] -= 1
            s |= 1 << C[j]  # C[j]桁目のbitを1にする
        key.append((s, a))
    INF = 10**9+7
    dp = [INF]*(2**n)
    dp[0] = 0

    for s in range(2**n):
        for i in range(m):
            t = s | key[i][0]
            cost = dp[s]+key[i][1]
            dp[t] = min(dp[t], cost)

    print(dp[-1] if dp[-1] != INF else -1)


resolve() import sys sys sys.setrecursionlimit(10 ** 5 + 10) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 + 10 10 ** 5 10 5 10 def input(): return sys.stdin.readline().strip() input def resolve():
    n, m = map(int, input().split())
    key = []  # 集合S，コスト
    for i in range(m):
        a, b = map(int, input().split())
        s = 0
        C = list(map(int, input().split()))
        for j in range(b):
            C[j] -= 1
            s |= 1 << C[j]  # C[j]桁目のbitを1にする
        key.append((s, a))
    INF = 10**9+7
    dp = [INF]*(2**n)
    dp[0] = 0

    for s in range(2**n):
        for i in range(m):
            t = s | key[i][0]
            cost = dp[s]+key[i][1]
            dp[t] = min(dp[t], cost)

    print(dp[-1] if dp[-1] != INF else -1) resolve n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m key = [] key [] for i in range(m):
        a, b = map(int, input().split())
        s = 0
        C = list(map(int, input().split()))
        for j in range(b):
            C[j] -= 1
            s |= 1 << C[j]  # C[j]桁目のbitを1にする
        key.append((s, a))
     i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b s = 0 s 0 C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for j in range(b):
            C[j] -= 1
            s |= 1 << C[j]  # C[j]桁目のbitを1にする
         j range(b) range b C[j] -= 1 C[j] C j 1 s |= 1 << C[j] s 1 << C[j] 1 C[j] C j key.append((s, a)) key.append key append (s, a) s a INF = 10**9+7 INF 10**9+7 10**9 10 9 7 dp = [INF]*(2**n) dp [INF]*(2**n) [INF] INF 2**n 2 n dp[0] = 0 dp[0] dp 0 0 for s in range(2**n):
        for i in range(m):
            t = s | key[i][0]
            cost = dp[s]+key[i][1]
            dp[t] = min(dp[t], cost)

     s range(2**n) range 2**n 2 n for i in range(m):
            t = s | key[i][0]
            cost = dp[s]+key[i][1]
            dp[t] = min(dp[t], cost)

     i range(m) range m t = s | key[i][0] t s | key[i][0] s key[i][0] [i] key i 0 cost = dp[s]+key[i][1] cost dp[s]+key[i][1] dp[s] dp s key[i][1] [i] key i 1 dp[t] = min(dp[t], cost) dp[t] dp t min(dp[t], cost) min dp[t] dp t cost print(dp[-1] if dp[-1] != INF else -1) print dp[-1] if dp[-1] != INF else -1 dp[-1] != INF dp[-1] dp -1 INF dp[-1] dp -1 -1 resolve() resolve def resolve():
    n, m = map(int, input().split())
    key = []  # 集合S，コスト
    for i in range(m):
        a, b = map(int, input().split())
        s = 0
        C = list(map(int, input().split()))
        for j in range(b):
            C[j] -= 1
            s |= 1 << C[j]  # C[j]桁目のbitを1にする
        key.append((s, a))
    INF = 10**9+7
    dp = [INF]*(2**n)
    dp[0] = 0

    for s in range(2**n):
        for i in range(m):
            t = s | key[i][0]
            cost = dp[s]+key[i][1]
            dp[t] = min(dp[t], cost)

    print(dp[-1] if dp[-1] != INF else -1) def resolve():
    n, m = map(int, input().split())
    key = []  # 集合S，コスト
    for i in range(m):
        a, b = map(int, input().split())
        s = 0
        C = list(map(int, input().split()))
        for j in range(b):
            C[j] -= 1
            s |= 1 << C[j]  # C[j]桁目のbitを1にする
        key.append((s, a))
    INF = 10**9+7
    dp = [INF]*(2**n)
    dp[0] = 0

    for s in range(2**n):
        for i in range(m):
            t = s | key[i][0]
            cost = dp[s]+key[i][1]
            dp[t] = min(dp[t], cost)

    print(dp[-1] if dp[-1] != INF else -1) resolve def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    n, m = map(int, input().split())
    key = []  # 集合S，コスト
    for i in range(m):
        a, b = map(int, input().split())
        s = 0
        C = list(map(int, input().split()))
        for j in range(b):
            C[j] -= 1
            s |= 1 << C[j]  # C[j]桁目のbitを1にする
        key.append((s, a))
    INF = 10**9+7
    dp = [INF]*(2**n)
    dp[0] = 0

    for s in range(2**n):
        for i in range(m):
            t = s | key[i][0]
            cost = dp[s]+key[i][1]
            dp[t] = min(dp[t], cost)

    print(dp[-1] if dp[-1] != INF else -1)


resolve()