#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    INF = 10**9


    N,M = LMIIS()
    keys = []
    for i in range(M):
        a,b = LMIIS()
        boxes = map(lambda x: int(x)-1, input().split())
        key = 0
        for b in boxes:
            key += 2**b
        keys.append((a,key))
        



    # 開けられる箱のパターン -> コスト
    dp = [INF] * 2 ** N
    dp[0] = 0

    for key_cost,key in keys:
        for box,cost in enumerate(dp):
            if cost != INF:
                dp[box|key] = min(dp[box|key], cost+key_cost)
    
    ans = dp[2**N-1]
    print(ans if ans != INF else -1)




    




if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 write = sys.stdout.write write sys.stdout.write sys.stdout sys stdout write dbg = lambda *something : print(*something) if DEBUG else 0 dbg lambda *something : print(*something) if DEBUG else 0 print(*something) if DEBUG else 0 DEBUG print(*something) print *something something 0 *something DEBUG = False DEBUG False def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    INF = 10**9


    N,M = LMIIS()
    keys = []
    for i in range(M):
        a,b = LMIIS()
        boxes = map(lambda x: int(x)-1, input().split())
        key = 0
        for b in boxes:
            key += 2**b
        keys.append((a,key))
        



    # 開けられる箱のパターン -> コスト
    dp = [INF] * 2 ** N
    dp[0] = 0

    for key_cost,key in keys:
        for box,cost in enumerate(dp):
            if cost != INF:
                dp[box|key] = min(dp[box|key], cost+key_cost)
    
    ans = dp[2**N-1]
    print(ans if ans != INF else -1)




     main input = lambda : given().rstrip() input lambda : given().rstrip() given().rstrip() ().rstrip () given rstrip LMIIS = lambda : list(map(int,input().split())) LMIIS lambda : list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split II = lambda : int(input()) II lambda : int(input()) int(input()) int input() input LMIIS() for _ in range(x) for _ in range(x) _ range(x) range x for _ in range(x) LMIIS() LMIIS XLMIIS = lambda x : [LMIIS() for _ in range(x)] XLMIIS lambda x : [LMIIS() for _ in range(x)] [LMIIS() for _ in range(x)] x INF = 10**9 INF 10**9 10 9 N,M = LMIIS() N LMIIS() LMIIS M keys = [] keys [] for i in range(M):
        a,b = LMIIS()
        boxes = map(lambda x: int(x)-1, input().split())
        key = 0
        for b in boxes:
            key += 2**b
        keys.append((a,key))
        



    # 開けられる箱のパターン -> コスト
     i range(M) range M a,b = LMIIS() a LMIIS() LMIIS b boxes = map(lambda x: int(x)-1, input().split()) boxes map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split key = 0 key 0 for b in boxes:
            key += 2**b
         b boxes key += 2**b key 2**b 2 b keys.append((a,key)) keys.append keys append (a,key) a key dp = [INF] * 2 ** N dp [INF] * 2 ** N [INF] INF 2 ** N 2 N dp[0] = 0 dp[0] dp 0 0 for key_cost,key in keys:
        for box,cost in enumerate(dp):
            if cost != INF:
                dp[box|key] = min(dp[box|key], cost+key_cost)
    
     key_cost key keys for box,cost in enumerate(dp):
            if cost != INF:
                dp[box|key] = min(dp[box|key], cost+key_cost)
    
     box cost enumerate(dp) enumerate dp if cost != INF:
                dp[box|key] = min(dp[box|key], cost+key_cost)
    
     cost != INF cost INF dp[box|key] = min(dp[box|key], cost+key_cost) dp[box|key] dp box|key box key min(dp[box|key], cost+key_cost) min dp[box|key] dp box|key box key cost+key_cost cost key_cost ans = dp[2**N-1] ans dp[2**N-1] dp 2**N-1 2**N 2 N 1 print(ans if ans != INF else -1) print ans if ans != INF else -1 ans != INF ans INF ans -1 given = sys.stdin.readline given sys.stdin.readline sys.stdin sys stdin readline if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main DEBUG = False False DEBUG write = sys.stdout.write sys.stdout.write write def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    INF = 10**9


    N,M = LMIIS()
    keys = []
    for i in range(M):
        a,b = LMIIS()
        boxes = map(lambda x: int(x)-1, input().split())
        key = 0
        for b in boxes:
            key += 2**b
        keys.append((a,key))
        



    # 開けられる箱のパターン -> コスト
    dp = [INF] * 2 ** N
    dp[0] = 0

    for key_cost,key in keys:
        for box,cost in enumerate(dp):
            if cost != INF:
                dp[box|key] = min(dp[box|key], cost+key_cost)
    
    ans = dp[2**N-1]
    print(ans if ans != INF else -1)




     def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    INF = 10**9


    N,M = LMIIS()
    keys = []
    for i in range(M):
        a,b = LMIIS()
        boxes = map(lambda x: int(x)-1, input().split())
        key = 0
        for b in boxes:
            key += 2**b
        keys.append((a,key))
        



    # 開けられる箱のパターン -> コスト
    dp = [INF] * 2 ** N
    dp[0] = 0

    for key_cost,key in keys:
        for box,cost in enumerate(dp):
            if cost != INF:
                dp[box|key] = min(dp[box|key], cost+key_cost)
    
    ans = dp[2**N-1]
    print(ans if ans != INF else -1)




     main dbg = lambda *something : print(*something) if DEBUG else 0 lambda *something : print(*something) if DEBUG else 0 dbg
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    INF = 10**9


    N,M = LMIIS()
    keys = []
    for i in range(M):
        a,b = LMIIS()
        boxes = map(lambda x: int(x)-1, input().split())
        key = 0
        for b in boxes:
            key += 2**b
        keys.append((a,key))
        



    # 開けられる箱のパターン -> コスト
    dp = [INF] * 2 ** N
    dp[0] = 0

    for key_cost,key in keys:
        for box,cost in enumerate(dp):
            if cost != INF:
                dp[box|key] = min(dp[box|key], cost+key_cost)
    
    ans = dp[2**N-1]
    print(ans if ans != INF else -1)




    




if __name__ == '__main__':
    main()