import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# dfs, dp, bit全探索
# 箱が12個以下
N, M = lr()
keys = [None] * M
for i in range(M):
    a, b = lr()
    C = lr()
    bit = 0
    for c in C:
        bit += 1 << (c-1)
    keys[i] = (a, bit)

INF = 10 ** 9
dp = [INF] * 2 ** N # 2**N - 1 が全ての箱を開けられる状態の最小値
dp[0] = 0
for key in keys:
    a, bit = key
    for i in range(2 ** N):
        dp[i|bit] = min(dp[i|bit], dp[i] + a)

print(-1 if dp[-1] == INF else dp[-1]) import sys sys sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N, M = lr() N lr() lr M keys = [None] * M keys [None] * M [None] None M for i in range(M):
    a, b = lr()
    C = lr()
    bit = 0
    for c in C:
        bit += 1 << (c-1)
    keys[i] = (a, bit) i range(M) range M a, b = lr() a lr() lr b C = lr() C lr() lr bit = 0 bit 0 for c in C:
        bit += 1 << (c-1)
     c C bit += 1 << (c-1) bit 1 << (c-1) 1 c-1 c 1 keys[i] = (a, bit) keys[i] keys i (a, bit) a bit INF = 10 ** 9 INF 10 ** 9 10 9 dp = [INF] * 2 ** N dp [INF] * 2 ** N [INF] INF 2 ** N 2 N dp[0] = 0 dp[0] dp 0 0 for key in keys:
    a, bit = key
    for i in range(2 ** N):
        dp[i|bit] = min(dp[i|bit], dp[i] + a) key keys a, bit = key a key bit for i in range(2 ** N):
        dp[i|bit] = min(dp[i|bit], dp[i] + a) i range(2 ** N) range 2 ** N 2 N dp[i|bit] = min(dp[i|bit], dp[i] + a) dp[i|bit] dp i|bit i bit min(dp[i|bit], dp[i] + a) min dp[i|bit] dp i|bit i bit dp[i] + a dp[i] dp i a print(-1 if dp[-1] == INF else dp[-1]) print -1 if dp[-1] == INF else dp[-1] dp[-1] == INF dp[-1] dp -1 INF -1 dp[-1] dp -1 N, M = lr() lr() N keys = [None] * M [None] * M keys INF = 10 ** 9 10 ** 9 INF sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr a, b = lr() lr() a C = lr() lr() C dp = [INF] * 2 ** N [INF] * 2 ** N dp ir = lambda: int(sr()) lambda: int(sr()) ir a, bit = key key a bit = 0 0 bit b = lr() lr() b bit += 1 << (c-1) 1 << (c-1) bit lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr bit = key key bit M = lr() lr() M
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# dfs, dp, bit全探索
# 箱が12個以下
N, M = lr()
keys = [None] * M
for i in range(M):
    a, b = lr()
    C = lr()
    bit = 0
    for c in C:
        bit += 1 << (c-1)
    keys[i] = (a, bit)

INF = 10 ** 9
dp = [INF] * 2 ** N # 2**N - 1 が全ての箱を開けられる状態の最小値
dp[0] = 0
for key in keys:
    a, bit = key
    for i in range(2 ** N):
        dp[i|bit] = min(dp[i|bit], dp[i] + a)

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