# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def tobit(N):
    ret = 0
    for n in N:
        ret |= (1 << n)
    
    return ret

N, M = LI()
C = []
for i in range(M):
    a, b = LI()
    C.append([a, tobit([x-1 for x in LI()])])

dp = [INF] * (1 << N)
dp[0] = 0

for i in range(1 << N):
    for cost, key in C:
        dp[i | key] = min(dp[i | key], dp[i] + cost)

print(dp[-1] if dp[-1] != INF else "-1") import sys sys import math math import collections collections import itertools itertools import bisect bisect INF = 10 ** 13 INF 10 ** 13 10 13 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def input() : return sys.stdin.readline().strip() input def lcm(x, y) : return (x * y) // math.gcd(x, y) lcm x x y y def I() : return int(input()) I int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x def LI() : return [int(x) for x in input().split()] LI int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input def RI(N) : return [int(input()) for _ in range(N)] RI N N [int(x) for x in input().split()] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [int(x) for x in input().split()] def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)] LRI N N def LS() : return input().split() LS input() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) input() input def RS(N) : return [input() for _ in range(N)] RS N N input().split() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) input().split() ().split () input split def LRS(N) : return [input().split() for _ in range(N)] LRS N N def PL(L) : print(*L, sep="\n") PL L L def YesNo(B) : print("Yes" if B else "No") YesNo B B def YESNO(B) : print("YES" if B else "NO") YESNO B B def tobit(N):
    ret = 0
    for n in N:
        ret |= (1 << n)
    
    return ret tobit ret = 0 ret 0 for n in N:
        ret |= (1 << n)
    
     n N ret |= (1 << n) ret 1 << n 1 n return ret ret N N N, M = LI() N LI() LI M C = [] C [] for i in range(M):
    a, b = LI()
    C.append([a, tobit([x-1 for x in LI()])]) i range(M) range M a, b = LI() a LI() LI b x-1 for x in LI() for x in LI() x LI() LI for x in LI() x-1 x 1 C.append([a, tobit([x-1 for x in LI()])]) C.append C append [a, tobit([x-1 for x in LI()])] a tobit([x-1 for x in LI()]) tobit [x-1 for x in LI()] dp = [INF] * (1 << N) dp [INF] * (1 << N) [INF] INF 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for i in range(1 << N):
    for cost, key in C:
        dp[i | key] = min(dp[i | key], dp[i] + cost) i range(1 << N) range 1 << N 1 N for cost, key in C:
        dp[i | key] = min(dp[i | key], dp[i] + cost) cost key C dp[i | key] = min(dp[i | key], dp[i] + cost) dp[i | key] dp i | key i key min(dp[i | key], dp[i] + cost) min dp[i | key] dp i | key i key dp[i] + cost dp[i] dp i cost 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" def YesNo(B) : print("Yes" if B else "No") def YesNo(B) : print("Yes" if B else "No") YesNo def tobit(N):
    ret = 0
    for n in N:
        ret |= (1 << n)
    
    return ret def tobit(N):
    ret = 0
    for n in N:
        ret |= (1 << n)
    
    return ret tobit def LRS(N) : return [input().split() for _ in range(N)] def LRS(N) : return [input().split() for _ in range(N)] LRS def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)] def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)] LRI MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def RS(N) : return [input() for _ in range(N)] def RS(N) : return [input() for _ in range(N)] RS N, M = LI() LI() N def input() : return sys.stdin.readline().strip() def input() : return sys.stdin.readline().strip() input dp = [INF] * (1 << N) [INF] * (1 << N) dp def I() : return int(input()) def I() : return int(input()) I def lcm(x, y) : return (x * y) // math.gcd(x, y) def lcm(x, y) : return (x * y) // math.gcd(x, y) lcm INF = 10 ** 13 10 ** 13 INF def YESNO(B) : print("YES" if B else "NO") def YESNO(B) : print("YES" if B else "NO") YESNO a, b = LI() LI() a M = LI() LI() M def PL(L) : print(*L, sep="\n") def PL(L) : print(*L, sep="\n") PL b = LI() LI() b def LI() : return [int(x) for x in input().split()] def LI() : return [int(x) for x in input().split()] LI C = [] [] C def LS() : return input().split() def LS() : return input().split() LS def RI(N) : return [int(input()) for _ in range(N)] def RI(N) : return [int(input()) for _ in range(N)] RI
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

def tobit(N):
    ret = 0
    for n in N:
        ret |= (1 << n)
    
    return ret

N, M = LI()
C = []
for i in range(M):
    a, b = LI()
    C.append([a, tobit([x-1 for x in LI()])])

dp = [INF] * (1 << N)
dp[0] = 0

for i in range(1 << N):
    for cost, key in C:
        dp[i | key] = min(dp[i | key], dp[i] + cost)

print(dp[-1] if dp[-1] != INF else "-1")
