import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    dp = [10**10 for _ in [0]*(2**n)]
    dp[0] = 0
    for _ in range(m):
        a,b = map(int,ipt().split())
        c = [int(i) for i in ipt().split()]
        opn = 0
        for i in c:
            opn += 2**(i-1)
        for i in range(2**n):
            if i&opn == 0:
                continue
            elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

    if dp[2**n-1] >= 10**10:
        print(-1)
    else:
        print(dp[2**n-1])
    return

if __name__ == '__main__':
    main() import math math import queue queue from collections import deque,defaultdict import heapq as hpq heapq from sys import stdin,setrecursionlimit ipt = stdin.readline ipt stdin.readline stdin readline setrecursionlimit(10**7) setrecursionlimit 10**7 10 7 def main():
    n,m = map(int,ipt().split())
    dp = [10**10 for _ in [0]*(2**n)]
    dp[0] = 0
    for _ in range(m):
        a,b = map(int,ipt().split())
        c = [int(i) for i in ipt().split()]
        opn = 0
        for i in c:
            opn += 2**(i-1)
        for i in range(2**n):
            if i&opn == 0:
                continue
            elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

    if dp[2**n-1] >= 10**10:
        print(-1)
    else:
        print(dp[2**n-1])
    return main n,m = map(int,ipt().split()) n map(int,ipt().split()) map int ipt().split() ().split () ipt split m 10**10 for _ in [0]*(2**n) for _ in [0]*(2**n) _ [0]*(2**n) [0] 0 2**n 2 n for _ in [0]*(2**n) 10**10 10 10 dp = [10**10 for _ in [0]*(2**n)] dp [10**10 for _ in [0]*(2**n)] dp[0] = 0 dp[0] dp 0 0 for _ in range(m):
        a,b = map(int,ipt().split())
        c = [int(i) for i in ipt().split()]
        opn = 0
        for i in c:
            opn += 2**(i-1)
        for i in range(2**n):
            if i&opn == 0:
                continue
            elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

     _ range(m) range m a,b = map(int,ipt().split()) a map(int,ipt().split()) map int ipt().split() ().split () ipt split b int(i) for i in ipt().split() for i in ipt().split() i ipt().split() ().split () ipt split for i in ipt().split() int(i) int i c = [int(i) for i in ipt().split()] c [int(i) for i in ipt().split()] opn = 0 opn 0 for i in c:
            opn += 2**(i-1)
         i c opn += 2**(i-1) opn 2**(i-1) 2 i-1 i 1 for i in range(2**n):
            if i&opn == 0:
                continue
            elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

     i range(2**n) range 2**n 2 n if i&opn == 0:
                continue
            elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

     i&opn == 0 i&opn i opn 0 continue elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

     dp[i] > dp[i-(i&opn)]+a dp[i] dp i dp[i-(i&opn)]+a dp[i-(i&opn)] dp i-(i&opn) i i&opn i opn a dp[i] = dp[i-(i&opn)]+a dp[i] dp i dp[i-(i&opn)]+a dp[i-(i&opn)] dp i-(i&opn) i i&opn i opn a if dp[2**n-1] >= 10**10:
        print(-1)
    else:
        print(dp[2**n-1])
     dp[2**n-1] >= 10**10 dp[2**n-1] dp 2**n-1 2**n 2 n 1 10**10 10 10 print(-1) print -1 print(dp[2**n-1]) print dp[2**n-1] dp 2**n-1 2**n 2 n 1 return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n,m = map(int,ipt().split())
    dp = [10**10 for _ in [0]*(2**n)]
    dp[0] = 0
    for _ in range(m):
        a,b = map(int,ipt().split())
        c = [int(i) for i in ipt().split()]
        opn = 0
        for i in c:
            opn += 2**(i-1)
        for i in range(2**n):
            if i&opn == 0:
                continue
            elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

    if dp[2**n-1] >= 10**10:
        print(-1)
    else:
        print(dp[2**n-1])
    return def main():
    n,m = map(int,ipt().split())
    dp = [10**10 for _ in [0]*(2**n)]
    dp[0] = 0
    for _ in range(m):
        a,b = map(int,ipt().split())
        c = [int(i) for i in ipt().split()]
        opn = 0
        for i in c:
            opn += 2**(i-1)
        for i in range(2**n):
            if i&opn == 0:
                continue
            elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

    if dp[2**n-1] >= 10**10:
        print(-1)
    else:
        print(dp[2**n-1])
    return main ipt = stdin.readline stdin.readline ipt
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    dp = [10**10 for _ in [0]*(2**n)]
    dp[0] = 0
    for _ in range(m):
        a,b = map(int,ipt().split())
        c = [int(i) for i in ipt().split()]
        opn = 0
        for i in c:
            opn += 2**(i-1)
        for i in range(2**n):
            if i&opn == 0:
                continue
            elif dp[i] > dp[i-(i&opn)]+a:
                dp[i] = dp[i-(i&opn)]+a

    if dp[2**n-1] >= 10**10:
        print(-1)
    else:
        print(dp[2**n-1])
    return

if __name__ == '__main__':
    main()
