# from pprint import pprint

N, M = map(int, input().split())
A = []
C = []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a)
    c = map(lambda x: int(x)-1, input().split())
    state = 0
    for ci in c:
        state |= 1 << ci
    C.append(state)

INF = 10**18
dp = [[INF]*2**N for _ in range(M)]
dp[0][0] = 0

for i in range(M-1):
    for state in range(1 << N):
        used = state | C[i]
        cur = dp[i][state]
        if dp[i+1][used] > cur + A[i]:
            dp[i+1][used] = dp[i][state] + A[i]

        if dp[i+1][state] > cur:
            dp[i+1][state] = cur

ans = dp[-1][-1]
print(ans if ans != INF else -1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = [] A [] C = [] C [] for _ in range(M):
    a, b = map(int, input().split())
    A.append(a)
    c = map(lambda x: int(x)-1, input().split())
    state = 0
    for ci in c:
        state |= 1 << ci
    C.append(state) _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A.append(a) A.append A append a c = map(lambda x: int(x)-1, input().split()) c map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split state = 0 state 0 for ci in c:
        state |= 1 << ci
     ci c state |= 1 << ci state 1 << ci 1 ci C.append(state) C.append C append state INF = 10**18 INF 10**18 10 18 [INF]*2**N for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [INF]*2**N [INF] INF 2**N 2 N dp = [[INF]*2**N for _ in range(M)] dp [[INF]*2**N for _ in range(M)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M-1):
    for state in range(1 << N):
        used = state | C[i]
        cur = dp[i][state]
        if dp[i+1][used] > cur + A[i]:
            dp[i+1][used] = dp[i][state] + A[i]

        if dp[i+1][state] > cur:
            dp[i+1][state] = cur i range(M-1) range M-1 M 1 for state in range(1 << N):
        used = state | C[i]
        cur = dp[i][state]
        if dp[i+1][used] > cur + A[i]:
            dp[i+1][used] = dp[i][state] + A[i]

        if dp[i+1][state] > cur:
            dp[i+1][state] = cur state range(1 << N) range 1 << N 1 N used = state | C[i] used state | C[i] state C[i] C i cur = dp[i][state] cur dp[i][state] [i] dp i state if dp[i+1][used] > cur + A[i]:
            dp[i+1][used] = dp[i][state] + A[i]

         dp[i+1][used] > cur + A[i] dp[i+1][used] [i+1] dp i+1 i 1 used cur + A[i] cur A[i] A i dp[i+1][used] = dp[i][state] + A[i] dp[i+1][used] [i+1] dp i+1 i 1 used dp[i][state] + A[i] dp[i][state] [i] dp i state A[i] A i if dp[i+1][state] > cur:
            dp[i+1][state] = cur dp[i+1][state] > cur dp[i+1][state] [i+1] dp i+1 i 1 state cur dp[i+1][state] = cur dp[i+1][state] [i+1] dp i+1 i 1 state cur ans = dp[-1][-1] ans dp[-1][-1] [-1] dp -1 -1 print(ans if ans != INF else -1) print ans if ans != INF else -1 ans != INF ans INF ans -1 C = [] [] C INF = 10**18 10**18 INF used = state | C[i] state | C[i] used state = 0 0 state a, b = map(int, input().split()) map(int, input().split()) a c = map(lambda x: int(x)-1, input().split()) map(lambda x: int(x)-1, input().split()) c b = map(int, input().split()) map(int, input().split()) b dp = [[INF]*2**N for _ in range(M)] [[INF]*2**N for _ in range(M)] dp A = [] [] A N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M cur = dp[i][state] dp[i][state] cur ans = dp[-1][-1] dp[-1][-1] ans state |= 1 << ci 1 << ci state
# from pprint import pprint

N, M = map(int, input().split())
A = []
C = []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a)
    c = map(lambda x: int(x)-1, input().split())
    state = 0
    for ci in c:
        state |= 1 << ci
    C.append(state)

INF = 10**18
dp = [[INF]*2**N for _ in range(M)]
dp[0][0] = 0

for i in range(M-1):
    for state in range(1 << N):
        used = state | C[i]
        cur = dp[i][state]
        if dp[i+1][used] > cur + A[i]:
            dp[i+1][used] = dp[i][state] + A[i]

        if dp[i+1][state] > cur:
            dp[i+1][state] = cur

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