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]*k for i in range(M+1)]
dp[0][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)
    for j in range(k):
        dp[i+1][j] = min(dp[i][j],dp[i+1][j])
        dp[i+1][j|d] = min(dp[i][j|d],dp[i][j]+a,dp[i+1][j|d])

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

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


