from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())
    
    key_price = [0]*M
    key_bit = [0]*M
    for i in range(M):
        key_price[i], b = map(int, input().split())
        c = list(map(int, input().split()))
        for j in range(b):
            key_bit[i] = key_bit[i] | (1 << (c[j] - 1))
    
    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for m in range(M):
        for bit in range(2**N):
            if dp[m][bit] == INF:
                continue
            dp[m+1][bit] = min(dp[m+1][bit], dp[m][bit])
            dp[m+1][bit | key_bit[m]] = min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m])

    res = dp[M][2**N-1]
    if res == INF:
        print(-1)
    else:
        print(res)


if __name__ == '__main__':
    main() from functools import reduce from fractions import gcd import math math import bisect bisect import itertools itertools import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline INF = float("inf") INF float("inf") float "inf" def main():
    N, M = map(int, input().split())
    
    key_price = [0]*M
    key_bit = [0]*M
    for i in range(M):
        key_price[i], b = map(int, input().split())
        c = list(map(int, input().split()))
        for j in range(b):
            key_bit[i] = key_bit[i] | (1 << (c[j] - 1))
    
    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for m in range(M):
        for bit in range(2**N):
            if dp[m][bit] == INF:
                continue
            dp[m+1][bit] = min(dp[m+1][bit], dp[m][bit])
            dp[m+1][bit | key_bit[m]] = min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m])

    res = dp[M][2**N-1]
    if res == INF:
        print(-1)
    else:
        print(res) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M key_price = [0]*M key_price [0]*M [0] 0 M key_bit = [0]*M key_bit [0]*M [0] 0 M for i in range(M):
        key_price[i], b = map(int, input().split())
        c = list(map(int, input().split()))
        for j in range(b):
            key_bit[i] = key_bit[i] | (1 << (c[j] - 1))
    
     i range(M) range M key_price[i], b = map(int, input().split()) key_price[i] key_price i 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 for j in range(b):
            key_bit[i] = key_bit[i] | (1 << (c[j] - 1))
    
     j range(b) range b key_bit[i] = key_bit[i] | (1 << (c[j] - 1)) key_bit[i] key_bit i key_bit[i] | (1 << (c[j] - 1)) key_bit[i] key_bit i 1 << (c[j] - 1) 1 c[j] - 1 c[j] c j 1 [INF] * (2**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] * (2**N) [INF] INF 2**N 2 N dp = [[INF] * (2**N) for _ in range(M+1)] dp [[INF] * (2**N) for _ in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for m in range(M):
        for bit in range(2**N):
            if dp[m][bit] == INF:
                continue
            dp[m+1][bit] = min(dp[m+1][bit], dp[m][bit])
            dp[m+1][bit | key_bit[m]] = min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m])

     m range(M) range M for bit in range(2**N):
            if dp[m][bit] == INF:
                continue
            dp[m+1][bit] = min(dp[m+1][bit], dp[m][bit])
            dp[m+1][bit | key_bit[m]] = min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m])

     bit range(2**N) range 2**N 2 N if dp[m][bit] == INF:
                continue
             dp[m][bit] == INF dp[m][bit] [m] dp m bit INF continue dp[m+1][bit] = min(dp[m+1][bit], dp[m][bit]) dp[m+1][bit] [m+1] dp m+1 m 1 bit min(dp[m+1][bit], dp[m][bit]) min dp[m+1][bit] [m+1] dp m+1 m 1 bit dp[m][bit] [m] dp m bit dp[m+1][bit | key_bit[m]] = min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m]) dp[m+1][bit | key_bit[m]] [m+1] dp m+1 m 1 bit | key_bit[m] bit key_bit[m] key_bit m min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m]) min dp[m+1][bit | key_bit[m]] [m+1] dp m+1 m 1 bit | key_bit[m] bit key_bit[m] key_bit m dp[m][bit] + key_price[m] dp[m][bit] [m] dp m bit key_price[m] key_price m res = dp[M][2**N-1] res dp[M][2**N-1] [M] dp M 2**N-1 2**N 2 N 1 if res == INF:
        print(-1)
    else:
        print(res) res == INF res INF print(-1) print -1 print(res) print res if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF = float("inf") float("inf") INF def main():
    N, M = map(int, input().split())
    
    key_price = [0]*M
    key_bit = [0]*M
    for i in range(M):
        key_price[i], b = map(int, input().split())
        c = list(map(int, input().split()))
        for j in range(b):
            key_bit[i] = key_bit[i] | (1 << (c[j] - 1))
    
    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for m in range(M):
        for bit in range(2**N):
            if dp[m][bit] == INF:
                continue
            dp[m+1][bit] = min(dp[m+1][bit], dp[m][bit])
            dp[m+1][bit | key_bit[m]] = min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m])

    res = dp[M][2**N-1]
    if res == INF:
        print(-1)
    else:
        print(res) def main():
    N, M = map(int, input().split())
    
    key_price = [0]*M
    key_bit = [0]*M
    for i in range(M):
        key_price[i], b = map(int, input().split())
        c = list(map(int, input().split()))
        for j in range(b):
            key_bit[i] = key_bit[i] | (1 << (c[j] - 1))
    
    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for m in range(M):
        for bit in range(2**N):
            if dp[m][bit] == INF:
                continue
            dp[m+1][bit] = min(dp[m+1][bit], dp[m][bit])
            dp[m+1][bit | key_bit[m]] = min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m])

    res = dp[M][2**N-1]
    if res == INF:
        print(-1)
    else:
        print(res) main input = sys.stdin.readline sys.stdin.readline input
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())
    
    key_price = [0]*M
    key_bit = [0]*M
    for i in range(M):
        key_price[i], b = map(int, input().split())
        c = list(map(int, input().split()))
        for j in range(b):
            key_bit[i] = key_bit[i] | (1 << (c[j] - 1))
    
    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for m in range(M):
        for bit in range(2**N):
            if dp[m][bit] == INF:
                continue
            dp[m+1][bit] = min(dp[m+1][bit], dp[m][bit])
            dp[m+1][bit | key_bit[m]] = min(dp[m+1][bit | key_bit[m]], dp[m][bit] + key_price[m])

    res = dp[M][2**N-1]
    if res == INF:
        print(-1)
    else:
        print(res)


if __name__ == '__main__':
    main()