INF = 10**9

def as_bit(ls):
    # 開けられる宝箱をbitで示す
    ret = 0
    for l in ls:
        ret |= 1 << (l - 1)
    return ret

def main():
    
    N, M = map(int, input().split())
    C, A = [], []
    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a)
        c = list(map(int, input().split()))
        C.append(as_bit(c))

    dp = [[INF] * (2**N) for _ in range(M+1)]

    for i in range(M+1):
        dp[i][0] = 0

    for i in range(M):
        for bit in range(2**N):
            dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]], dp[i][bit] + A[i])
            dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit])

    ans = dp[-1][-1]
    print(ans if ans != INF else -1)

if __name__ == "__main__":
    main() INF = 10**9 INF 10**9 10 9 def as_bit(ls):
    # 開けられる宝箱をbitで示す
    ret = 0
    for l in ls:
        ret |= 1 << (l - 1)
    return ret as_bit ret = 0 ret 0 for l in ls:
        ret |= 1 << (l - 1)
     l ls ret |= 1 << (l - 1) ret 1 << (l - 1) 1 l - 1 l 1 return ret ret ls ls def main():
    
    N, M = map(int, input().split())
    C, A = [], []
    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a)
        c = list(map(int, input().split()))
        C.append(as_bit(c))

    dp = [[INF] * (2**N) for _ in range(M+1)]

    for i in range(M+1):
        dp[i][0] = 0

    for i in range(M):
        for bit in range(2**N):
            dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]], dp[i][bit] + A[i])
            dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit])

    ans = dp[-1][-1]
    print(ans if ans != INF else -1) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M C, A = [], [] C [] A [] for _ in range(M):
        a, b = map(int, input().split())
        A.append(a)
        c = list(map(int, input().split()))
        C.append(as_bit(c))

     _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A.append(a) A.append A append a c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split C.append(as_bit(c)) C.append C append as_bit(c) as_bit c [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)] for i in range(M+1):
        dp[i][0] = 0

     i range(M+1) range M+1 M 1 dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for i in range(M):
        for bit in range(2**N):
            dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]], dp[i][bit] + A[i])
            dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit])

     i range(M) range M for bit in range(2**N):
            dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]], dp[i][bit] + A[i])
            dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit])

     bit range(2**N) range 2**N 2 N dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]], dp[i][bit] + A[i]) dp[i+1][bit|C[i]] [i+1] dp i+1 i 1 bit|C[i] bit C[i] C i min(dp[i+1][bit|C[i]], dp[i][bit] + A[i]) min dp[i+1][bit|C[i]] [i+1] dp i+1 i 1 bit|C[i] bit C[i] C i dp[i][bit] + A[i] dp[i][bit] [i] dp i bit A[i] A i dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit]) dp[i+1][bit] [i+1] dp i+1 i 1 bit min(dp[i+1][bit], dp[i][bit]) min dp[i+1][bit] [i+1] dp i+1 i 1 bit dp[i][bit] [i] dp i bit ans = dp[-1][-1] ans dp[-1][-1] [-1] dp -1 -1 print(ans if ans != INF else -1) print ans if ans != INF else -1 ans != INF ans INF ans -1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main INF = 10**9 10**9 INF def as_bit(ls):
    # 開けられる宝箱をbitで示す
    ret = 0
    for l in ls:
        ret |= 1 << (l - 1)
    return ret def as_bit(ls):
    # 開けられる宝箱をbitで示す
    ret = 0
    for l in ls:
        ret |= 1 << (l - 1)
    return ret as_bit def main():
    
    N, M = map(int, input().split())
    C, A = [], []
    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a)
        c = list(map(int, input().split()))
        C.append(as_bit(c))

    dp = [[INF] * (2**N) for _ in range(M+1)]

    for i in range(M+1):
        dp[i][0] = 0

    for i in range(M):
        for bit in range(2**N):
            dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]], dp[i][bit] + A[i])
            dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit])

    ans = dp[-1][-1]
    print(ans if ans != INF else -1) def main():
    
    N, M = map(int, input().split())
    C, A = [], []
    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a)
        c = list(map(int, input().split()))
        C.append(as_bit(c))

    dp = [[INF] * (2**N) for _ in range(M+1)]

    for i in range(M+1):
        dp[i][0] = 0

    for i in range(M):
        for bit in range(2**N):
            dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]], dp[i][bit] + A[i])
            dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit])

    ans = dp[-1][-1]
    print(ans if ans != INF else -1) main
INF = 10**9

def as_bit(ls):
    # 開けられる宝箱をbitで示す
    ret = 0
    for l in ls:
        ret |= 1 << (l - 1)
    return ret

def main():
    
    N, M = map(int, input().split())
    C, A = [], []
    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a)
        c = list(map(int, input().split()))
        C.append(as_bit(c))

    dp = [[INF] * (2**N) for _ in range(M+1)]

    for i in range(M+1):
        dp[i][0] = 0

    for i in range(M):
        for bit in range(2**N):
            dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]], dp[i][bit] + A[i])
            dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit])

    ans = dp[-1][-1]
    print(ans if ans != INF else -1)

if __name__ == "__main__":
    main()
