N, M = map(int, input().split())
A = [0] * M
B = [0] * M
C = [0]*M
for m in range(M):
    A[m], B[m] = map(int, input().split())
    C[m] = [int(cm) for cm in input().split()]

INF = 100000000
dp = [[INF] * 2**N for _ in range(M + 1)]
dp[0][0] = 0


def Set2Bit(st):
    bt = ["0"]*N
    for i in st:
        bt[i-1] = "1"
    return bt


for m in range(0, M):
    key = Set2Bit(C[m])
    key_bit = int("".join(key), 2)
    for bit in range(2**N):
        pre_bit = next_bit = bit
        dp[m+1][next_bit] = dp[m][pre_bit]
    for bit in range(2**N):
        pre_bit = bit
        next_bit = pre_bit | key_bit
        dp[m+1][next_bit] = min(dp[m+1][next_bit], dp[m][next_bit], dp[m][pre_bit] + A[m])

if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1]) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = [0] * M A [0] * M [0] 0 M B = [0] * M B [0] * M [0] 0 M C = [0]*M C [0]*M [0] 0 M for m in range(M):
    A[m], B[m] = map(int, input().split())
    C[m] = [int(cm) for cm in input().split()] m range(M) range M A[m], B[m] = map(int, input().split()) A[m] A m map(int, input().split()) map int input().split() ().split () input split B[m] B m int(cm) for cm in input().split() for cm in input().split() cm input().split() ().split () input split for cm in input().split() int(cm) int cm C[m] = [int(cm) for cm in input().split()] C[m] C m [int(cm) for cm in input().split()] INF = 100000000 INF 100000000 [INF] * 2**N for _ in range(M + 1) for _ in range(M + 1) _ range(M + 1) range M + 1 M 1 for _ in range(M + 1) [INF] * 2**N [INF] INF 2**N 2 N dp = [[INF] * 2**N for _ in range(M + 1)] dp [[INF] * 2**N for _ in range(M + 1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 def Set2Bit(st):
    bt = ["0"]*N
    for i in st:
        bt[i-1] = "1"
    return bt Set2Bit bt = ["0"]*N bt ["0"]*N ["0"] "0" N for i in st:
        bt[i-1] = "1"
     i st bt[i-1] = "1" bt[i-1] bt i-1 i 1 "1" return bt bt st st for m in range(0, M):
    key = Set2Bit(C[m])
    key_bit = int("".join(key), 2)
    for bit in range(2**N):
        pre_bit = next_bit = bit
        dp[m+1][next_bit] = dp[m][pre_bit]
    for bit in range(2**N):
        pre_bit = bit
        next_bit = pre_bit | key_bit
        dp[m+1][next_bit] = min(dp[m+1][next_bit], dp[m][next_bit], dp[m][pre_bit] + A[m]) m range(0, M) range 0 M key = Set2Bit(C[m]) key Set2Bit(C[m]) Set2Bit C[m] C m key_bit = int("".join(key), 2) key_bit int("".join(key), 2) int "".join(key) "".join "" join key 2 for bit in range(2**N):
        pre_bit = next_bit = bit
        dp[m+1][next_bit] = dp[m][pre_bit]
     bit range(2**N) range 2**N 2 N pre_bit = next_bit = bit pre_bit bit = next_bit = bit next_bit bit dp[m+1][next_bit] = dp[m][pre_bit] dp[m+1][next_bit] [m+1] dp m+1 m 1 next_bit dp[m][pre_bit] [m] dp m pre_bit for bit in range(2**N):
        pre_bit = bit
        next_bit = pre_bit | key_bit
        dp[m+1][next_bit] = min(dp[m+1][next_bit], dp[m][next_bit], dp[m][pre_bit] + A[m]) bit range(2**N) range 2**N 2 N pre_bit = bit pre_bit bit next_bit = pre_bit | key_bit next_bit pre_bit | key_bit pre_bit key_bit dp[m+1][next_bit] = min(dp[m+1][next_bit], dp[m][next_bit], dp[m][pre_bit] + A[m]) dp[m+1][next_bit] [m+1] dp m+1 m 1 next_bit min(dp[m+1][next_bit], dp[m][next_bit], dp[m][pre_bit] + A[m]) min dp[m+1][next_bit] [m+1] dp m+1 m 1 next_bit dp[m][next_bit] [m] dp m next_bit dp[m][pre_bit] + A[m] dp[m][pre_bit] [m] dp m pre_bit A[m] A m if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1]) dp[-1][-1] == INF dp[-1][-1] [-1] dp -1 -1 INF print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 key_bit = int("".join(key), 2) int("".join(key), 2) key_bit pre_bit = next_bit = bit bit pre_bit next_bit = pre_bit | key_bit pre_bit | key_bit next_bit N, M = map(int, input().split()) map(int, input().split()) N B = [0] * M [0] * M B M = map(int, input().split()) map(int, input().split()) M next_bit = bit bit next_bit key = Set2Bit(C[m]) Set2Bit(C[m]) key A = [0] * M [0] * M A C = [0]*M [0]*M C dp = [[INF] * 2**N for _ in range(M + 1)] [[INF] * 2**N for _ in range(M + 1)] dp INF = 100000000 100000000 INF def Set2Bit(st):
    bt = ["0"]*N
    for i in st:
        bt[i-1] = "1"
    return bt def Set2Bit(st):
    bt = ["0"]*N
    for i in st:
        bt[i-1] = "1"
    return bt Set2Bit pre_bit = bit bit pre_bit
N, M = map(int, input().split())
A = [0] * M
B = [0] * M
C = [0]*M
for m in range(M):
    A[m], B[m] = map(int, input().split())
    C[m] = [int(cm) for cm in input().split()]

INF = 100000000
dp = [[INF] * 2**N for _ in range(M + 1)]
dp[0][0] = 0


def Set2Bit(st):
    bt = ["0"]*N
    for i in st:
        bt[i-1] = "1"
    return bt


for m in range(0, M):
    key = Set2Bit(C[m])
    key_bit = int("".join(key), 2)
    for bit in range(2**N):
        pre_bit = next_bit = bit
        dp[m+1][next_bit] = dp[m][pre_bit]
    for bit in range(2**N):
        pre_bit = bit
        next_bit = pre_bit | key_bit
        dp[m+1][next_bit] = min(dp[m+1][next_bit], dp[m][next_bit], dp[m][pre_bit] + A[m])

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