# N = int(input())
N, M = [int(i) for i in input().split()]
key = []
for i in range(M):
    a, b = [int(_) for _ in input().split()]
    cs = [int(_) for _ in input().split()]
    s = 0
    for c in cs:
        c -= 1
        s |= 1 << c
    key.append([s, a])

INF = 10**9
dp = [INF for i in range(2**N)]
dp[0] = 0
for i in range(2**N):
    for j in range(M):
        t = i | key[j][0]
        cost = key[j][1]
        dp[t] = min(dp[t], dp[i] + cost)
ans = dp[-1]
if ans == INF:
    print(-1)
else:
    print(ans)
 int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i N, M = [int(i) for i in input().split()] N [int(i) for i in input().split()] M key = [] key [] for i in range(M):
    a, b = [int(_) for _ in input().split()]
    cs = [int(_) for _ in input().split()]
    s = 0
    for c in cs:
        c -= 1
        s |= 1 << c
    key.append([s, a]) i range(M) range M int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ a, b = [int(_) for _ in input().split()] a [int(_) for _ in input().split()] b int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ cs = [int(_) for _ in input().split()] cs [int(_) for _ in input().split()] s = 0 s 0 for c in cs:
        c -= 1
        s |= 1 << c
     c cs c -= 1 c 1 s |= 1 << c s 1 << c 1 c key.append([s, a]) key.append key append [s, a] s a INF = 10**9 INF 10**9 10 9 INF for i in range(2**N) for i in range(2**N) i range(2**N) range 2**N 2 N for i in range(2**N) INF dp = [INF for i in range(2**N)] dp [INF for i in range(2**N)] dp[0] = 0 dp[0] dp 0 0 for i in range(2**N):
    for j in range(M):
        t = i | key[j][0]
        cost = key[j][1]
        dp[t] = min(dp[t], dp[i] + cost) i range(2**N) range 2**N 2 N for j in range(M):
        t = i | key[j][0]
        cost = key[j][1]
        dp[t] = min(dp[t], dp[i] + cost) j range(M) range M t = i | key[j][0] t i | key[j][0] i key[j][0] [j] key j 0 cost = key[j][1] cost key[j][1] [j] key j 1 dp[t] = min(dp[t], dp[i] + cost) dp[t] dp t min(dp[t], dp[i] + cost) min dp[t] dp t dp[i] + cost dp[i] dp i cost ans = dp[-1] ans dp[-1] dp -1 if ans == INF:
    print(-1)
else:
    print(ans) ans == INF ans INF print(-1) print -1 print(ans) print ans dp = [INF for i in range(2**N)] [INF for i in range(2**N)] dp ans = dp[-1] dp[-1] ans b = [int(_) for _ in input().split()] [int(_) for _ in input().split()] b N, M = [int(i) for i in input().split()] [int(i) for i in input().split()] N t = i | key[j][0] i | key[j][0] t cost = key[j][1] key[j][1] cost c -= 1 1 c key = [] [] key s = 0 0 s M = [int(i) for i in input().split()] [int(i) for i in input().split()] M cs = [int(_) for _ in input().split()] [int(_) for _ in input().split()] cs a, b = [int(_) for _ in input().split()] [int(_) for _ in input().split()] a INF = 10**9 10**9 INF s |= 1 << c 1 << c s
# N = int(input())
N, M = [int(i) for i in input().split()]
key = []
for i in range(M):
    a, b = [int(_) for _ in input().split()]
    cs = [int(_) for _ in input().split()]
    s = 0
    for c in cs:
        c -= 1
        s |= 1 << c
    key.append([s, a])

INF = 10**9
dp = [INF for i in range(2**N)]
dp[0] = 0
for i in range(2**N):
    for j in range(M):
        t = i | key[j][0]
        cost = key[j][1]
        dp[t] = min(dp[t], dp[i] + cost)
ans = dp[-1]
if ans == INF:
    print(-1)
else:
    print(ans)

