
def resolve():
    INF = 10 ** 18
    N, M = map(int, input().split())

    Box_key = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = sum(1 << (c - 1) for c in C)
        Box_key.append((s, a))

    # dp[i]: 集合iの宝箱を開ける最小コスト
    dp = [INF] * (1 << N)
    dp[0] = 0

    for s in range(1 << N):
        for i in range(M):
            ns = s | Box_key[i][0]
            cost = dp[s] + Box_key[i][1]
            dp[ns] = min(dp[ns], cost)

    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])


if __name__ == "__main__":
    resolve() def resolve():
    INF = 10 ** 18
    N, M = map(int, input().split())

    Box_key = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = sum(1 << (c - 1) for c in C)
        Box_key.append((s, a))

    # dp[i]: 集合iの宝箱を開ける最小コスト
    dp = [INF] * (1 << N)
    dp[0] = 0

    for s in range(1 << N):
        for i in range(M):
            ns = s | Box_key[i][0]
            cost = dp[s] + Box_key[i][1]
            dp[ns] = min(dp[ns], cost)

    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1]) resolve INF = 10 ** 18 INF 10 ** 18 10 18 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M Box_key = [] Box_key [] for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = sum(1 << (c - 1) for c in C)
        Box_key.append((s, a))

    # dp[i]: 集合iの宝箱を開ける最小コスト
     i 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 s = sum(1 << (c - 1) for c in C) s sum(1 << (c - 1) for c in C) sum 1 << (c - 1) 1 c - 1 c 1 Box_key.append((s, a)) Box_key.append Box_key append (s, a) s a dp = [INF] * (1 << N) dp [INF] * (1 << N) [INF] INF 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for s in range(1 << N):
        for i in range(M):
            ns = s | Box_key[i][0]
            cost = dp[s] + Box_key[i][1]
            dp[ns] = min(dp[ns], cost)

     s range(1 << N) range 1 << N 1 N for i in range(M):
            ns = s | Box_key[i][0]
            cost = dp[s] + Box_key[i][1]
            dp[ns] = min(dp[ns], cost)

     i range(M) range M ns = s | Box_key[i][0] ns s | Box_key[i][0] s Box_key[i][0] [i] Box_key i 0 cost = dp[s] + Box_key[i][1] cost dp[s] + Box_key[i][1] dp[s] dp s Box_key[i][1] [i] Box_key i 1 dp[ns] = min(dp[ns], cost) dp[ns] dp ns min(dp[ns], cost) min dp[ns] dp ns cost if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1]) dp[(1 << N) - 1] == INF dp[(1 << N) - 1] dp (1 << N) - 1 1 << N 1 N 1 INF print(-1) print -1 print(dp[(1 << N) - 1]) print dp[(1 << N) - 1] dp (1 << N) - 1 1 << N 1 N 1 if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    INF = 10 ** 18
    N, M = map(int, input().split())

    Box_key = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = sum(1 << (c - 1) for c in C)
        Box_key.append((s, a))

    # dp[i]: 集合iの宝箱を開ける最小コスト
    dp = [INF] * (1 << N)
    dp[0] = 0

    for s in range(1 << N):
        for i in range(M):
            ns = s | Box_key[i][0]
            cost = dp[s] + Box_key[i][1]
            dp[ns] = min(dp[ns], cost)

    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1]) def resolve():
    INF = 10 ** 18
    N, M = map(int, input().split())

    Box_key = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = sum(1 << (c - 1) for c in C)
        Box_key.append((s, a))

    # dp[i]: 集合iの宝箱を開ける最小コスト
    dp = [INF] * (1 << N)
    dp[0] = 0

    for s in range(1 << N):
        for i in range(M):
            ns = s | Box_key[i][0]
            cost = dp[s] + Box_key[i][1]
            dp[ns] = min(dp[ns], cost)

    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1]) resolve

def resolve():
    INF = 10 ** 18
    N, M = map(int, input().split())

    Box_key = []
    for i in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        s = sum(1 << (c - 1) for c in C)
        Box_key.append((s, a))

    # dp[i]: 集合iの宝箱を開ける最小コスト
    dp = [INF] * (1 << N)
    dp[0] = 0

    for s in range(1 << N):
        for i in range(M):
            ns = s | Box_key[i][0]
            cost = dp[s] + Box_key[i][1]
            dp[ns] = min(dp[ns], cost)

    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])


if __name__ == "__main__":
    resolve()