N, M = map(int, input().split())

dp =[[float("inf") for _ in range(2 ** N)] for _ in range(M + 1)]
dp[0][0] = 0

for i in range(M):
    A, B = map(int, input().split())
    C = list(map(int, input().split()))
    tmp = [0 for _ in range(N)]
    for c in C:
        tmp[c - 1] = 1
    x = int("".join(map(str, tmp)), 2)
    for j in range(2 ** N):
        dp[i + 1][x|j] = min(dp[i][x|j], dp[i][j] + A, dp[i + 1][x|j])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

ans = dp[M][2 ** N - 1]
if ans != float("inf"):
    print(ans)
else:
    print(-1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M [float("inf") for _ in range(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) [float("inf") for _ in range(2 ** N)] dp =[[float("inf") for _ in range(2 ** N)] for _ in range(M + 1)] dp [[float("inf") for _ in range(2 ** N)] for _ 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, input().split())
    C = list(map(int, input().split()))
    tmp = [0 for _ in range(N)]
    for c in C:
        tmp[c - 1] = 1
    x = int("".join(map(str, tmp)), 2)
    for j in range(2 ** N):
        dp[i + 1][x|j] = min(dp[i][x|j], dp[i][j] + A, dp[i + 1][x|j])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) i range(M) range M A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 tmp = [0 for _ in range(N)] tmp [0 for _ in range(N)] for c in C:
        tmp[c - 1] = 1
     c C tmp[c - 1] = 1 tmp[c - 1] tmp c - 1 c 1 1 x = int("".join(map(str, tmp)), 2) x int("".join(map(str, tmp)), 2) int "".join(map(str, tmp)) "".join "" join map(str, tmp) map str tmp 2 for j in range(2 ** N):
        dp[i + 1][x|j] = min(dp[i][x|j], dp[i][j] + A, dp[i + 1][x|j])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) j range(2 ** N) range 2 ** N 2 N dp[i + 1][x|j] = min(dp[i][x|j], dp[i][j] + A, dp[i + 1][x|j]) dp[i + 1][x|j] [i + 1] dp i + 1 i 1 x|j x j min(dp[i][x|j], dp[i][j] + A, dp[i + 1][x|j]) min dp[i][x|j] [i] dp i x|j x j dp[i][j] + A dp[i][j] [i] dp i j A dp[i + 1][x|j] [i + 1] dp i + 1 i 1 x|j x j dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) dp[i + 1][j] [i + 1] dp i + 1 i 1 j min(dp[i + 1][j], dp[i][j]) min dp[i + 1][j] [i + 1] dp i + 1 i 1 j dp[i][j] [i] dp i j ans = dp[M][2 ** N - 1] ans dp[M][2 ** N - 1] [M] dp M 2 ** N - 1 2 ** N 2 N 1 if ans != float("inf"):
    print(ans)
else:
    print(-1) ans != float("inf") ans float("inf") float "inf" print(ans) print ans print(-1) print -1 M = map(int, input().split()) map(int, input().split()) M C = list(map(int, input().split())) list(map(int, input().split())) C A, B = map(int, input().split()) map(int, input().split()) A dp =[[float("inf") for _ in range(2 ** N)] for _ in range(M + 1)] [[float("inf") for _ in range(2 ** N)] for _ in range(M + 1)] dp B = map(int, input().split()) map(int, input().split()) B x = int("".join(map(str, tmp)), 2) int("".join(map(str, tmp)), 2) x ans = dp[M][2 ** N - 1] dp[M][2 ** N - 1] ans tmp = [0 for _ in range(N)] [0 for _ in range(N)] tmp N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())

dp =[[float("inf") for _ in range(2 ** N)] for _ in range(M + 1)]
dp[0][0] = 0

for i in range(M):
    A, B = map(int, input().split())
    C = list(map(int, input().split()))
    tmp = [0 for _ in range(N)]
    for c in C:
        tmp[c - 1] = 1
    x = int("".join(map(str, tmp)), 2)
    for j in range(2 ** N):
        dp[i + 1][x|j] = min(dp[i][x|j], dp[i][j] + A, dp[i + 1][x|j])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

ans = dp[M][2 ** N - 1]
if ans != float("inf"):
    print(ans)
else:
    print(-1)