import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 

def makebin(arr):
    ret = 0
    for num in arr:
        ret += 2 ** (num - 1)

    return ret

def main():
    n, m = getList()
    dp = [INF] * (2 ** n)
    dp[0] = 0
    for i in range(m):
        a, b = getList()
        tgt = getList()
        kagi = makebin(tgt)
        for i, d in enumerate(dp):
            if d != -1:
                dp[i|kagi] = min(dp[i|kagi], d + a)
        # print(dp, kagi)

    if dp[-1] == INF:
        print(-1)
        return 
    print(dp[-1])
    # print(0&1)?






 
if __name__ == "__main__":
    main()
    import sys sys from collections import defaultdict, deque, Counter import math math from bisect import bisect_left, bisect_right input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline getS = lambda: input().strip() getS lambda: input().strip() input().strip() ().strip () input strip getN = lambda: int(input()) getN lambda: int(input()) int(input()) int input() input getList = lambda: list(map(int, input().split())) getList lambda: list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split int(x) - 1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) - 1 int(x) int x 1 getZList = lambda: [int(x) - 1 for x in input().split()] getZList lambda: [int(x) - 1 for x in input().split()] [int(x) - 1 for x in input().split()] INF = 10 ** 20 INF 10 ** 20 10 20 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 divide = lambda x: pow(x, MOD-2, MOD) divide lambda x: pow(x, MOD-2, MOD) pow(x, MOD-2, MOD) pow x MOD-2 MOD 2 MOD x def makebin(arr):
    ret = 0
    for num in arr:
        ret += 2 ** (num - 1)

    return ret makebin ret = 0 ret 0 for num in arr:
        ret += 2 ** (num - 1)

     num arr ret += 2 ** (num - 1) ret 2 ** (num - 1) 2 num - 1 num 1 return ret ret arr arr def main():
    n, m = getList()
    dp = [INF] * (2 ** n)
    dp[0] = 0
    for i in range(m):
        a, b = getList()
        tgt = getList()
        kagi = makebin(tgt)
        for i, d in enumerate(dp):
            if d != -1:
                dp[i|kagi] = min(dp[i|kagi], d + a)
        # print(dp, kagi)

    if dp[-1] == INF:
        print(-1)
        return 
    print(dp[-1])
    # print(0&1)?






  main n, m = getList() n getList() getList m dp = [INF] * (2 ** n) dp [INF] * (2 ** n) [INF] INF 2 ** n 2 n dp[0] = 0 dp[0] dp 0 0 for i in range(m):
        a, b = getList()
        tgt = getList()
        kagi = makebin(tgt)
        for i, d in enumerate(dp):
            if d != -1:
                dp[i|kagi] = min(dp[i|kagi], d + a)
        # print(dp, kagi)

     i range(m) range m a, b = getList() a getList() getList b tgt = getList() tgt getList() getList kagi = makebin(tgt) kagi makebin(tgt) makebin tgt for i, d in enumerate(dp):
            if d != -1:
                dp[i|kagi] = min(dp[i|kagi], d + a)
        # print(dp, kagi)

     i d enumerate(dp) enumerate dp if d != -1:
                dp[i|kagi] = min(dp[i|kagi], d + a)
        # print(dp, kagi)

     d != -1 d -1 dp[i|kagi] = min(dp[i|kagi], d + a) dp[i|kagi] dp i|kagi i kagi min(dp[i|kagi], d + a) min dp[i|kagi] dp i|kagi i kagi d + a d a if dp[-1] == INF:
        print(-1)
        return 
     dp[-1] == INF dp[-1] dp -1 INF print(-1) print -1 return print(dp[-1]) print dp[-1] dp -1 if __name__ == "__main__":
    main()
    __name__ == "__main__" __name__ "__main__" main() main getZList = lambda: [int(x) - 1 for x in input().split()] lambda: [int(x) - 1 for x in input().split()] getZList INF = 10 ** 20 10 ** 20 INF getList = lambda: list(map(int, input().split())) lambda: list(map(int, input().split())) getList def makebin(arr):
    ret = 0
    for num in arr:
        ret += 2 ** (num - 1)

    return ret def makebin(arr):
    ret = 0
    for num in arr:
        ret += 2 ** (num - 1)

    return ret makebin getS = lambda: input().strip() lambda: input().strip() getS MOD = 10**9 + 7 10**9 + 7 MOD input = sys.stdin.readline sys.stdin.readline input divide = lambda x: pow(x, MOD-2, MOD) lambda x: pow(x, MOD-2, MOD) divide def main():
    n, m = getList()
    dp = [INF] * (2 ** n)
    dp[0] = 0
    for i in range(m):
        a, b = getList()
        tgt = getList()
        kagi = makebin(tgt)
        for i, d in enumerate(dp):
            if d != -1:
                dp[i|kagi] = min(dp[i|kagi], d + a)
        # print(dp, kagi)

    if dp[-1] == INF:
        print(-1)
        return 
    print(dp[-1])
    # print(0&1)?






  def main():
    n, m = getList()
    dp = [INF] * (2 ** n)
    dp[0] = 0
    for i in range(m):
        a, b = getList()
        tgt = getList()
        kagi = makebin(tgt)
        for i, d in enumerate(dp):
            if d != -1:
                dp[i|kagi] = min(dp[i|kagi], d + a)
        # print(dp, kagi)

    if dp[-1] == INF:
        print(-1)
        return 
    print(dp[-1])
    # print(0&1)?






  main getN = lambda: int(input()) lambda: int(input()) getN
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 

def makebin(arr):
    ret = 0
    for num in arr:
        ret += 2 ** (num - 1)

    return ret

def main():
    n, m = getList()
    dp = [INF] * (2 ** n)
    dp[0] = 0
    for i in range(m):
        a, b = getList()
        tgt = getList()
        kagi = makebin(tgt)
        for i, d in enumerate(dp):
            if d != -1:
                dp[i|kagi] = min(dp[i|kagi], d + a)
        # print(dp, kagi)

    if dp[-1] == INF:
        print(-1)
        return 
    print(dp[-1])
    # print(0&1)?






 
if __name__ == "__main__":
    main()
   