import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N, M = read_values()
    K = []
    for _ in range(M):
        a, _ = read_values()
        T = read_list()
        K.append((a, T))

    dp = [10 ** 8] * (2 ** N + 10)
    dp[0] = 0
    for a, T in K:
        k = 0
        for t in T:
            k += 1 << (t - 1)
        for i in range(2 ** N):
            dp[i | k] = min(dp[i | k], dp[i] + a) 

    res = dp[2 ** N - 1]
    print(res if res != 10 ** 8 else -1)

if __name__ == "__main__":
    main() import sys sys import itertools itertools input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def read_values():
    return map(int, input().split()) read_values return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def read_list():
    return list(read_values()) read_list return list(read_values()) list(read_values()) list read_values() read_values def read_lists(N):
    return [read_list() for n in range(N)] read_lists read_list() for n in range(N) for n in range(N) n range(N) range N for n in range(N) read_list() read_list return [read_list() for n in range(N)] [read_list() for n in range(N)] N N def main():
    N, M = read_values()
    K = []
    for _ in range(M):
        a, _ = read_values()
        T = read_list()
        K.append((a, T))

    dp = [10 ** 8] * (2 ** N + 10)
    dp[0] = 0
    for a, T in K:
        k = 0
        for t in T:
            k += 1 << (t - 1)
        for i in range(2 ** N):
            dp[i | k] = min(dp[i | k], dp[i] + a) 

    res = dp[2 ** N - 1]
    print(res if res != 10 ** 8 else -1) main N, M = read_values() N read_values() read_values M K = [] K [] for _ in range(M):
        a, _ = read_values()
        T = read_list()
        K.append((a, T))

     _ range(M) range M a, _ = read_values() a read_values() read_values _ T = read_list() T read_list() read_list K.append((a, T)) K.append K append (a, T) a T dp = [10 ** 8] * (2 ** N + 10) dp [10 ** 8] * (2 ** N + 10) [10 ** 8] 10 ** 8 10 8 2 ** N + 10 2 ** N 2 N 10 dp[0] = 0 dp[0] dp 0 0 for a, T in K:
        k = 0
        for t in T:
            k += 1 << (t - 1)
        for i in range(2 ** N):
            dp[i | k] = min(dp[i | k], dp[i] + a) 

     a T K k = 0 k 0 for t in T:
            k += 1 << (t - 1)
         t T k += 1 << (t - 1) k 1 << (t - 1) 1 t - 1 t 1 for i in range(2 ** N):
            dp[i | k] = min(dp[i | k], dp[i] + a) 

     i range(2 ** N) range 2 ** N 2 N dp[i | k] = min(dp[i | k], dp[i] + a) dp[i | k] dp i | k i k min(dp[i | k], dp[i] + a) min dp[i | k] dp i | k i k dp[i] + a dp[i] dp i a res = dp[2 ** N - 1] res dp[2 ** N - 1] dp 2 ** N - 1 2 ** N 2 N 1 print(res if res != 10 ** 8 else -1) print res if res != 10 ** 8 else -1 res != 10 ** 8 res 10 ** 8 10 8 res -1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.readline sys.stdin.readline input def read_lists(N):
    return [read_list() for n in range(N)] def read_lists(N):
    return [read_list() for n in range(N)] read_lists def read_values():
    return map(int, input().split()) def read_values():
    return map(int, input().split()) read_values def main():
    N, M = read_values()
    K = []
    for _ in range(M):
        a, _ = read_values()
        T = read_list()
        K.append((a, T))

    dp = [10 ** 8] * (2 ** N + 10)
    dp[0] = 0
    for a, T in K:
        k = 0
        for t in T:
            k += 1 << (t - 1)
        for i in range(2 ** N):
            dp[i | k] = min(dp[i | k], dp[i] + a) 

    res = dp[2 ** N - 1]
    print(res if res != 10 ** 8 else -1) def main():
    N, M = read_values()
    K = []
    for _ in range(M):
        a, _ = read_values()
        T = read_list()
        K.append((a, T))

    dp = [10 ** 8] * (2 ** N + 10)
    dp[0] = 0
    for a, T in K:
        k = 0
        for t in T:
            k += 1 << (t - 1)
        for i in range(2 ** N):
            dp[i | k] = min(dp[i | k], dp[i] + a) 

    res = dp[2 ** N - 1]
    print(res if res != 10 ** 8 else -1) main def read_list():
    return list(read_values()) def read_list():
    return list(read_values()) read_list
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N, M = read_values()
    K = []
    for _ in range(M):
        a, _ = read_values()
        T = read_list()
        K.append((a, T))

    dp = [10 ** 8] * (2 ** N + 10)
    dp[0] = 0
    for a, T in K:
        k = 0
        for t in T:
            k += 1 << (t - 1)
        for i in range(2 ** N):
            dp[i | k] = min(dp[i | k], dp[i] + a) 

    res = dp[2 ** N - 1]
    print(res if res != 10 ** 8 else -1)

if __name__ == "__main__":
    main()
