N, M = map(int, input().split())
BIT = 2 ** N
dp =[[float("inf") for _ in range(BIT)] 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()))
    x = sum([2 ** (c - 1) for c in C])
    for j in range(BIT):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][x|j] = min(dp[i][j] + A, dp[i + 1][x|j])

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

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