def main():
    INF = 10 ** 10
    N, M = list(map(int, input().split(' ')))
    key_list = list()
    for _ in range(M):
        A, _ = list(map(int, input().split(' ')))
        C = list(map(lambda x: int(x) - 1, input().split(' ')))
        boxes = 0
        for c in C:
            boxes |= (1 << c)
        key_list.append((A, boxes))
    # bit DP
    # dp[m][S]: m個目までのカギでSに含まれる宝箱を開けるための最小費用
    dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)]
    for m in range(M + 1):
        dp[m][0] = 0
    for m in range(1, M + 1):
        cost, box = key_list[m - 1]
        for S in range(1 << N):
            dp[m][S] = min(dp[m][S], dp[m - 1][S])
            if box | S != S:
                dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost)
    ans = dp[M][(1 << N) - 1]
    if ans >= INF:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main() def main():
    INF = 10 ** 10
    N, M = list(map(int, input().split(' ')))
    key_list = list()
    for _ in range(M):
        A, _ = list(map(int, input().split(' ')))
        C = list(map(lambda x: int(x) - 1, input().split(' ')))
        boxes = 0
        for c in C:
            boxes |= (1 << c)
        key_list.append((A, boxes))
    # bit DP
    # dp[m][S]: m個目までのカギでSに含まれる宝箱を開けるための最小費用
    dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)]
    for m in range(M + 1):
        dp[m][0] = 0
    for m in range(1, M + 1):
        cost, box = key_list[m - 1]
        for S in range(1 << N):
            dp[m][S] = min(dp[m][S], dp[m - 1][S])
            if box | S != S:
                dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost)
    ans = dp[M][(1 << N) - 1]
    if ans >= INF:
        print(-1)
    else:
        print(ans) main INF = 10 ** 10 INF 10 ** 10 10 10 N, M = list(map(int, input().split(' '))) N list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' M key_list = list() key_list list() list for _ in range(M):
        A, _ = list(map(int, input().split(' ')))
        C = list(map(lambda x: int(x) - 1, input().split(' ')))
        boxes = 0
        for c in C:
            boxes |= (1 << c)
        key_list.append((A, boxes))
    # bit DP
    # dp[m][S]: m個目までのカギでSに含まれる宝箱を開けるための最小費用
     _ range(M) range M A, _ = list(map(int, input().split(' '))) A list(map(int, input().split(' '))) list map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' _ C = list(map(lambda x: int(x) - 1, input().split(' '))) C list(map(lambda x: int(x) - 1, input().split(' '))) list map(lambda x: int(x) - 1, input().split(' ')) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x input().split(' ') ().split () input split ' ' boxes = 0 boxes 0 for c in C:
            boxes |= (1 << c)
         c C boxes |= (1 << c) boxes 1 << c 1 c key_list.append((A, boxes)) key_list.append key_list append (A, boxes) A boxes [INF for _ in range(1 << N)] for _ in range(M + 1) for _ in range(M + 1) _ range(M + 1) range M + 1 M 1 for _ in range(M + 1) [INF for _ in range(1 << N)] dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)] dp [[INF for _ in range(1 << N)] for _ in range(M + 1)] for m in range(M + 1):
        dp[m][0] = 0
     m range(M + 1) range M + 1 M 1 dp[m][0] = 0 dp[m][0] [m] dp m 0 0 for m in range(1, M + 1):
        cost, box = key_list[m - 1]
        for S in range(1 << N):
            dp[m][S] = min(dp[m][S], dp[m - 1][S])
            if box | S != S:
                dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost)
     m range(1, M + 1) range 1 M + 1 M 1 cost, box = key_list[m - 1] cost key_list[m - 1] key_list m - 1 m 1 box for S in range(1 << N):
            dp[m][S] = min(dp[m][S], dp[m - 1][S])
            if box | S != S:
                dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost)
     S range(1 << N) range 1 << N 1 N dp[m][S] = min(dp[m][S], dp[m - 1][S]) dp[m][S] [m] dp m S min(dp[m][S], dp[m - 1][S]) min dp[m][S] [m] dp m S dp[m - 1][S] [m - 1] dp m - 1 m 1 S if box | S != S:
                dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost)
     box | S != S box | S box S S dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost) dp[m][box | S] [m] dp m box | S box S min(dp[m][box | S], dp[m - 1][S] + cost) min dp[m][box | S] [m] dp m box | S box S dp[m - 1][S] + cost dp[m - 1][S] [m - 1] dp m - 1 m 1 S cost ans = dp[M][(1 << N) - 1] ans dp[M][(1 << N) - 1] [M] dp M (1 << N) - 1 1 << N 1 N 1 if ans >= INF:
        print(-1)
    else:
        print(ans) ans >= INF ans INF print(-1) print -1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    INF = 10 ** 10
    N, M = list(map(int, input().split(' ')))
    key_list = list()
    for _ in range(M):
        A, _ = list(map(int, input().split(' ')))
        C = list(map(lambda x: int(x) - 1, input().split(' ')))
        boxes = 0
        for c in C:
            boxes |= (1 << c)
        key_list.append((A, boxes))
    # bit DP
    # dp[m][S]: m個目までのカギでSに含まれる宝箱を開けるための最小費用
    dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)]
    for m in range(M + 1):
        dp[m][0] = 0
    for m in range(1, M + 1):
        cost, box = key_list[m - 1]
        for S in range(1 << N):
            dp[m][S] = min(dp[m][S], dp[m - 1][S])
            if box | S != S:
                dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost)
    ans = dp[M][(1 << N) - 1]
    if ans >= INF:
        print(-1)
    else:
        print(ans) def main():
    INF = 10 ** 10
    N, M = list(map(int, input().split(' ')))
    key_list = list()
    for _ in range(M):
        A, _ = list(map(int, input().split(' ')))
        C = list(map(lambda x: int(x) - 1, input().split(' ')))
        boxes = 0
        for c in C:
            boxes |= (1 << c)
        key_list.append((A, boxes))
    # bit DP
    # dp[m][S]: m個目までのカギでSに含まれる宝箱を開けるための最小費用
    dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)]
    for m in range(M + 1):
        dp[m][0] = 0
    for m in range(1, M + 1):
        cost, box = key_list[m - 1]
        for S in range(1 << N):
            dp[m][S] = min(dp[m][S], dp[m - 1][S])
            if box | S != S:
                dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost)
    ans = dp[M][(1 << N) - 1]
    if ans >= INF:
        print(-1)
    else:
        print(ans) main
def main():
    INF = 10 ** 10
    N, M = list(map(int, input().split(' ')))
    key_list = list()
    for _ in range(M):
        A, _ = list(map(int, input().split(' ')))
        C = list(map(lambda x: int(x) - 1, input().split(' ')))
        boxes = 0
        for c in C:
            boxes |= (1 << c)
        key_list.append((A, boxes))
    # bit DP
    # dp[m][S]: m個目までのカギでSに含まれる宝箱を開けるための最小費用
    dp = [[INF for _ in range(1 << N)] for _ in range(M + 1)]
    for m in range(M + 1):
        dp[m][0] = 0
    for m in range(1, M + 1):
        cost, box = key_list[m - 1]
        for S in range(1 << N):
            dp[m][S] = min(dp[m][S], dp[m - 1][S])
            if box | S != S:
                dp[m][box | S] = min(dp[m][box | S], dp[m - 1][S] + cost)
    ans = dp[M][(1 << N) - 1]
    if ans >= INF:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()
