import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A, C = [], []
    for _ in range(m):
        a, b = map(int, input().split())
        A.append(a)
        key = 0
        for c in map(int, input().split()):
            key |= 1 << (c - 1)
        C.append(key)

    dp = [f_inf] * (1 << n)
    dp[0] = 0
    for S in range(1 << n):
        for i in range(m):
            key, cost = C[i], A[i]
            dp[S | key] = min(dp[S | key], dp[S] + cost)
    print(dp[-1] if dp[-1] != f_inf else -1)


if __name__ == '__main__':
    resolve() import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 f_inf = float('inf') f_inf float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def resolve():
    n, m = map(int, input().split())
    A, C = [], []
    for _ in range(m):
        a, b = map(int, input().split())
        A.append(a)
        key = 0
        for c in map(int, input().split()):
            key |= 1 << (c - 1)
        C.append(key)

    dp = [f_inf] * (1 << n)
    dp[0] = 0
    for S in range(1 << n):
        for i in range(m):
            key, cost = C[i], A[i]
            dp[S | key] = min(dp[S | key], dp[S] + cost)
    print(dp[-1] if dp[-1] != f_inf else -1) resolve n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m A, C = [], [] A [] C [] for _ in range(m):
        a, b = map(int, input().split())
        A.append(a)
        key = 0
        for c in map(int, input().split()):
            key |= 1 << (c - 1)
        C.append(key)

     _ range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A.append(a) A.append A append a key = 0 key 0 for c in map(int, input().split()):
            key |= 1 << (c - 1)
         c map(int, input().split()) map int input().split() ().split () input split key |= 1 << (c - 1) key 1 << (c - 1) 1 c - 1 c 1 C.append(key) C.append C append key dp = [f_inf] * (1 << n) dp [f_inf] * (1 << n) [f_inf] f_inf 1 << n 1 n dp[0] = 0 dp[0] dp 0 0 for S in range(1 << n):
        for i in range(m):
            key, cost = C[i], A[i]
            dp[S | key] = min(dp[S | key], dp[S] + cost)
     S range(1 << n) range 1 << n 1 n for i in range(m):
            key, cost = C[i], A[i]
            dp[S | key] = min(dp[S | key], dp[S] + cost)
     i range(m) range m key, cost = C[i], A[i] key C[i] C i cost A[i] A i dp[S | key] = min(dp[S | key], dp[S] + cost) dp[S | key] dp S | key S key min(dp[S | key], dp[S] + cost) min dp[S | key] dp S | key S key dp[S] + cost dp[S] dp S cost print(dp[-1] if dp[-1] != f_inf else -1) print dp[-1] if dp[-1] != f_inf else -1 dp[-1] != f_inf dp[-1] dp -1 f_inf dp[-1] dp -1 -1 if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve def resolve():
    n, m = map(int, input().split())
    A, C = [], []
    for _ in range(m):
        a, b = map(int, input().split())
        A.append(a)
        key = 0
        for c in map(int, input().split()):
            key |= 1 << (c - 1)
        C.append(key)

    dp = [f_inf] * (1 << n)
    dp[0] = 0
    for S in range(1 << n):
        for i in range(m):
            key, cost = C[i], A[i]
            dp[S | key] = min(dp[S | key], dp[S] + cost)
    print(dp[-1] if dp[-1] != f_inf else -1) def resolve():
    n, m = map(int, input().split())
    A, C = [], []
    for _ in range(m):
        a, b = map(int, input().split())
        A.append(a)
        key = 0
        for c in map(int, input().split()):
            key |= 1 << (c - 1)
        C.append(key)

    dp = [f_inf] * (1 << n)
    dp[0] = 0
    for S in range(1 << n):
        for i in range(m):
            key, cost = C[i], A[i]
            dp[S | key] = min(dp[S | key], dp[S] + cost)
    print(dp[-1] if dp[-1] != f_inf else -1) resolve mod = 10 ** 9 + 7 10 ** 9 + 7 mod f_inf = float('inf') float('inf') f_inf
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A, C = [], []
    for _ in range(m):
        a, b = map(int, input().split())
        A.append(a)
        key = 0
        for c in map(int, input().split()):
            key |= 1 << (c - 1)
        C.append(key)

    dp = [f_inf] * (1 << n)
    dp[0] = 0
    for S in range(1 << n):
        for i in range(m):
            key, cost = C[i], A[i]
            dp[S | key] = min(dp[S | key], dp[S] + cost)
    print(dp[-1] if dp[-1] != f_inf else -1)


if __name__ == '__main__':
    resolve()
