import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,M = map(int,readline().split())
k = 2**N
dp = [INF for i in range(k)]
dp[0] = 0

for i in range(M):
    a,b = map(int,readline().split())
    c = list(map(int,readline().split()))
    d = sum(1<<(ci-1) for ci in c)
    dpnew = dp[:]
    for j in range(k):
        dpnew[j|d] = min(dp[j]+a,dpnew[j|d])
    dp = dpnew

print(dp[2**N-1] if dp[2**N-1] != INF else -1)

 import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 INF = 10**18 INF 10**18 10 18 eps = 10**-7 eps 10**-7 10 -7 N,M = map(int,readline().split()) N map(int,readline().split()) map int readline().split() ().split () readline split M k = 2**N k 2**N 2 N INF for i in range(k) for i in range(k) i range(k) range k for i in range(k) INF dp = [INF for i in range(k)] dp [INF for i in range(k)] dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    a,b = map(int,readline().split())
    c = list(map(int,readline().split()))
    d = sum(1<<(ci-1) for ci in c)
    dpnew = dp[:]
    for j in range(k):
        dpnew[j|d] = min(dp[j]+a,dpnew[j|d])
    dp = dpnew i range(M) range M a,b = map(int,readline().split()) a map(int,readline().split()) map int readline().split() ().split () readline split b c = list(map(int,readline().split())) c list(map(int,readline().split())) list map(int,readline().split()) map int readline().split() ().split () readline split d = sum(1<<(ci-1) for ci in c) d sum(1<<(ci-1) for ci in c) sum 1<<(ci-1) 1 ci-1 ci 1 dpnew = dp[:] dpnew dp[:] dp : for j in range(k):
        dpnew[j|d] = min(dp[j]+a,dpnew[j|d])
     j range(k) range k dpnew[j|d] = min(dp[j]+a,dpnew[j|d]) dpnew[j|d] dpnew j|d j d min(dp[j]+a,dpnew[j|d]) min dp[j]+a dp[j] dp j a dpnew[j|d] dpnew j|d j d dp = dpnew dp dpnew print(dp[2**N-1] if dp[2**N-1] != INF else -1) print dp[2**N-1] if dp[2**N-1] != INF else -1 dp[2**N-1] != INF dp[2**N-1] dp 2**N-1 2**N 2 N 1 INF dp[2**N-1] dp 2**N-1 2**N 2 N 1 -1 mod = 10**9+7 10**9+7 mod dp = dpnew dpnew dp dp = [INF for i in range(k)] [INF for i in range(k)] dp a,b = map(int,readline().split()) map(int,readline().split()) a k = 2**N 2**N k N,M = map(int,readline().split()) map(int,readline().split()) N dpnew = dp[:] dp[:] dpnew INF = 10**18 10**18 INF eps = 10**-7 10**-7 eps M = map(int,readline().split()) map(int,readline().split()) M readline = sys.stdin.readline sys.stdin.readline readline b = map(int,readline().split()) map(int,readline().split()) b d = sum(1<<(ci-1) for ci in c) sum(1<<(ci-1) for ci in c) d c = list(map(int,readline().split())) list(map(int,readline().split())) c
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,M = map(int,readline().split())
k = 2**N
dp = [INF for i in range(k)]
dp[0] = 0

for i in range(M):
    a,b = map(int,readline().split())
    c = list(map(int,readline().split()))
    d = sum(1<<(ci-1) for ci in c)
    dpnew = dp[:]
    for j in range(k):
        dpnew[j|d] = min(dp[j]+a,dpnew[j|d])
    dp = dpnew

print(dp[2**N-1] if dp[2**N-1] != INF else -1)


