def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    # key[i]:10進数でiを開けれる鍵の値段
    key = []
    for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key.append((binary, a))

    # dp[i]:10進数で宝iを開けてる時の最小値段
    dp = [inf]*(1<<n)
    dp[0] = 0
    for i, a in key:
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
    print(dp[-1] if dp[-1] != inf else -1)

if __name__ == '__main__':
    main() def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    # key[i]:10進数でiを開けれる鍵の値段
    key = []
    for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key.append((binary, a))

    # dp[i]:10進数で宝iを開けてる時の最小値段
    dp = [inf]*(1<<n)
    dp[0] = 0
    for i, a in key:
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
    print(dp[-1] if dp[-1] != inf else -1) main import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 from collections import Counter, deque from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush import math math inf = 10**17 inf 10**17 10 17 n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m key = [] key [] for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key.append((binary, a))

    # dp[i]:10進数で宝iを開けてる時の最小値段
     _ range(m) range m a,b = map(int, input().split()) a 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 binary = 0 binary 0 for i in c:
            binary += 2**(i-1)
         i c binary += 2**(i-1) binary 2**(i-1) 2 i-1 i 1 key.append((binary, a)) key.append key append (binary, a) binary a dp = [inf]*(1<<n) dp [inf]*(1<<n) [inf] inf 1<<n 1 n dp[0] = 0 dp[0] dp 0 0 for i, a in key:
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
     i a key for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
     s range(1<<n) range 1<<n 1 n if (i|s) == s:
                continue
             (i|s) == s i|s i s s continue dp[i|s] = min(dp[i|s], dp[s]+a) dp[i|s] dp i|s i s min(dp[i|s], dp[s]+a) min dp[i|s] dp i|s i s dp[s]+a dp[s] dp s a print(dp[-1] if dp[-1] != inf else -1) print dp[-1] if dp[-1] != inf else -1 dp[-1] != inf dp[-1] dp -1 inf dp[-1] dp -1 -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    # key[i]:10進数でiを開けれる鍵の値段
    key = []
    for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key.append((binary, a))

    # dp[i]:10進数で宝iを開けてる時の最小値段
    dp = [inf]*(1<<n)
    dp[0] = 0
    for i, a in key:
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
    print(dp[-1] if dp[-1] != inf else -1) def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    # key[i]:10進数でiを開けれる鍵の値段
    key = []
    for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key.append((binary, a))

    # dp[i]:10進数で宝iを開けてる時の最小値段
    dp = [inf]*(1<<n)
    dp[0] = 0
    for i, a in key:
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
    print(dp[-1] if dp[-1] != inf else -1) main
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    # key[i]:10進数でiを開けれる鍵の値段
    key = []
    for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key.append((binary, a))

    # dp[i]:10進数で宝iを開けてる時の最小値段
    dp = [inf]*(1<<n)
    dp[0] = 0
    for i, a in key:
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
    print(dp[-1] if dp[-1] != inf else -1)

if __name__ == '__main__':
    main()
