import sys

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


def resolve():
    n, m = map(int, input().split())
    ABC = []
    for _ in range(m):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        bit = ["0"] * n
        for c in C:
            bit[c - 1] = "1"

        bit = "".join(bit)
        ABC.append([a, b, int(bit, 2)])

    dp = [f_inf for _ in range(1 << n)]
    dp[0] = 0
    for i in range(1 << n):
        for a, b, c in ABC:
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)

    if dp[-1] != f_inf:
        print(dp[-1])
    else:
        print(-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())
    ABC = []
    for _ in range(m):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        bit = ["0"] * n
        for c in C:
            bit[c - 1] = "1"

        bit = "".join(bit)
        ABC.append([a, b, int(bit, 2)])

    dp = [f_inf for _ in range(1 << n)]
    dp[0] = 0
    for i in range(1 << n):
        for a, b, c in ABC:
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)

    if dp[-1] != f_inf:
        print(dp[-1])
    else:
        print(-1) resolve n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ABC = [] ABC [] for _ in range(m):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        bit = ["0"] * n
        for c in C:
            bit[c - 1] = "1"

        bit = "".join(bit)
        ABC.append([a, b, int(bit, 2)])

     _ range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bit = ["0"] * n bit ["0"] * n ["0"] "0" n for c in C:
            bit[c - 1] = "1"

         c C bit[c - 1] = "1" bit[c - 1] bit c - 1 c 1 "1" bit = "".join(bit) bit "".join(bit) "".join "" join bit ABC.append([a, b, int(bit, 2)]) ABC.append ABC append [a, b, int(bit, 2)] a b int(bit, 2) int bit 2 f_inf for _ in range(1 << n) for _ in range(1 << n) _ range(1 << n) range 1 << n 1 n for _ in range(1 << n) f_inf dp = [f_inf for _ in range(1 << n)] dp [f_inf for _ in range(1 << n)] dp[0] = 0 dp[0] dp 0 0 for i in range(1 << n):
        for a, b, c in ABC:
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)

     i range(1 << n) range 1 << n 1 n for a, b, c in ABC:
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)

     a b c ABC idx = i | c idx i | c i c dp[idx] = min(dp[idx], dp[i] + a) dp[idx] dp idx min(dp[idx], dp[i] + a) min dp[idx] dp idx dp[i] + a dp[i] dp i a if dp[-1] != f_inf:
        print(dp[-1])
    else:
        print(-1) dp[-1] != f_inf dp[-1] dp -1 f_inf print(dp[-1]) print dp[-1] dp -1 print(-1) print -1 if __name__ == '__main__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve def resolve():
    n, m = map(int, input().split())
    ABC = []
    for _ in range(m):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        bit = ["0"] * n
        for c in C:
            bit[c - 1] = "1"

        bit = "".join(bit)
        ABC.append([a, b, int(bit, 2)])

    dp = [f_inf for _ in range(1 << n)]
    dp[0] = 0
    for i in range(1 << n):
        for a, b, c in ABC:
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)

    if dp[-1] != f_inf:
        print(dp[-1])
    else:
        print(-1) def resolve():
    n, m = map(int, input().split())
    ABC = []
    for _ in range(m):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        bit = ["0"] * n
        for c in C:
            bit[c - 1] = "1"

        bit = "".join(bit)
        ABC.append([a, b, int(bit, 2)])

    dp = [f_inf for _ in range(1 << n)]
    dp[0] = 0
    for i in range(1 << n):
        for a, b, c in ABC:
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)

    if dp[-1] != f_inf:
        print(dp[-1])
    else:
        print(-1) resolve f_inf = float('inf') float('inf') f_inf mod = 10 ** 9 + 7 10 ** 9 + 7 mod
import sys

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


def resolve():
    n, m = map(int, input().split())
    ABC = []
    for _ in range(m):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        bit = ["0"] * n
        for c in C:
            bit[c - 1] = "1"

        bit = "".join(bit)
        ABC.append([a, b, int(bit, 2)])

    dp = [f_inf for _ in range(1 << n)]
    dp[0] = 0
    for i in range(1 << n):
        for a, b, c in ABC:
            idx = i | c
            dp[idx] = min(dp[idx], dp[i] + a)

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


if __name__ == '__main__':
    resolve()
