def main():
    n,m = tuple([int(t)for t in input().split()])

    keys = []

    dp = [10**9]*(1<<n)
    dp[0] = 0
    for _ in range(m):
        a,_ = tuple([int(t)for t in input().split()])
        c = tuple([int(t)for t in input().split()])
        key = 0
        for c_i in c:
            key |= 1<<(c_i-1)
        keys.append((a,key))
    

    for a,key in keys:
        for i in range(1<<n):
            dp[i|key] = min(dp[i|key],dp[i]+a)

    if dp[-1]==10**9:
        print(-1)
    else:
        print(dp[-1])
if __name__ == "__main__":
    main() def main():
    n,m = tuple([int(t)for t in input().split()])

    keys = []

    dp = [10**9]*(1<<n)
    dp[0] = 0
    for _ in range(m):
        a,_ = tuple([int(t)for t in input().split()])
        c = tuple([int(t)for t in input().split()])
        key = 0
        for c_i in c:
            key |= 1<<(c_i-1)
        keys.append((a,key))
    

    for a,key in keys:
        for i in range(1<<n):
            dp[i|key] = min(dp[i|key],dp[i]+a)

    if dp[-1]==10**9:
        print(-1)
    else:
        print(dp[-1]) main int(t)for t in input().split() for t in input().split() t input().split() ().split () input split for t in input().split() int(t) int t n,m = tuple([int(t)for t in input().split()]) n tuple([int(t)for t in input().split()]) tuple [int(t)for t in input().split()] m keys = [] keys [] dp = [10**9]*(1<<n) dp [10**9]*(1<<n) [10**9] 10**9 10 9 1<<n 1 n dp[0] = 0 dp[0] dp 0 0 for _ in range(m):
        a,_ = tuple([int(t)for t in input().split()])
        c = tuple([int(t)for t in input().split()])
        key = 0
        for c_i in c:
            key |= 1<<(c_i-1)
        keys.append((a,key))
    

     _ range(m) range m int(t)for t in input().split() for t in input().split() t input().split() ().split () input split for t in input().split() int(t) int t a,_ = tuple([int(t)for t in input().split()]) a tuple([int(t)for t in input().split()]) tuple [int(t)for t in input().split()] _ int(t)for t in input().split() for t in input().split() t input().split() ().split () input split for t in input().split() int(t) int t c = tuple([int(t)for t in input().split()]) c tuple([int(t)for t in input().split()]) tuple [int(t)for t in input().split()] key = 0 key 0 for c_i in c:
            key |= 1<<(c_i-1)
         c_i c key |= 1<<(c_i-1) key 1<<(c_i-1) 1 c_i-1 c_i 1 keys.append((a,key)) keys.append keys append (a,key) a key for a,key in keys:
        for i in range(1<<n):
            dp[i|key] = min(dp[i|key],dp[i]+a)

     a key keys for i in range(1<<n):
            dp[i|key] = min(dp[i|key],dp[i]+a)

     i range(1<<n) range 1<<n 1 n dp[i|key] = min(dp[i|key],dp[i]+a) dp[i|key] dp i|key i key min(dp[i|key],dp[i]+a) min dp[i|key] dp i|key i key dp[i]+a dp[i] dp i a if dp[-1]==10**9:
        print(-1)
    else:
        print(dp[-1]) dp[-1]==10**9 dp[-1] dp -1 10**9 10 9 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n,m = tuple([int(t)for t in input().split()])

    keys = []

    dp = [10**9]*(1<<n)
    dp[0] = 0
    for _ in range(m):
        a,_ = tuple([int(t)for t in input().split()])
        c = tuple([int(t)for t in input().split()])
        key = 0
        for c_i in c:
            key |= 1<<(c_i-1)
        keys.append((a,key))
    

    for a,key in keys:
        for i in range(1<<n):
            dp[i|key] = min(dp[i|key],dp[i]+a)

    if dp[-1]==10**9:
        print(-1)
    else:
        print(dp[-1]) def main():
    n,m = tuple([int(t)for t in input().split()])

    keys = []

    dp = [10**9]*(1<<n)
    dp[0] = 0
    for _ in range(m):
        a,_ = tuple([int(t)for t in input().split()])
        c = tuple([int(t)for t in input().split()])
        key = 0
        for c_i in c:
            key |= 1<<(c_i-1)
        keys.append((a,key))
    

    for a,key in keys:
        for i in range(1<<n):
            dp[i|key] = min(dp[i|key],dp[i]+a)

    if dp[-1]==10**9:
        print(-1)
    else:
        print(dp[-1]) main
def main():
    n,m = tuple([int(t)for t in input().split()])

    keys = []

    dp = [10**9]*(1<<n)
    dp[0] = 0
    for _ in range(m):
        a,_ = tuple([int(t)for t in input().split()])
        c = tuple([int(t)for t in input().split()])
        key = 0
        for c_i in c:
            key |= 1<<(c_i-1)
        keys.append((a,key))
    

    for a,key in keys:
        for i in range(1<<n):
            dp[i|key] = min(dp[i|key],dp[i]+a)

    if dp[-1]==10**9:
        print(-1)
    else:
        print(dp[-1])
if __name__ == "__main__":
    main()
