n, m = map(int, input().split())
inf = 10 ** 9
dp = [0] + [inf] * ((1 << n) - 1)
for _ in range(m):
    newdp = [p for p in dp]
    a, b = map(int, input().split())
    c = sum(1 << (int(i) - 1) for i in input().split())
    for bits in range(len(dp)):
        newdp[bits | c] = min(newdp[bits | c], dp[bits] + a)
    dp = newdp
print(-1 if dp[-1] == inf else dp[-1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m inf = 10 ** 9 inf 10 ** 9 10 9 dp = [0] + [inf] * ((1 << n) - 1) dp [0] + [inf] * ((1 << n) - 1) [0] 0 [inf] * ((1 << n) - 1) [inf] inf (1 << n) - 1 1 << n 1 n 1 for _ in range(m):
    newdp = [p for p in dp]
    a, b = map(int, input().split())
    c = sum(1 << (int(i) - 1) for i in input().split())
    for bits in range(len(dp)):
        newdp[bits | c] = min(newdp[bits | c], dp[bits] + a)
    dp = newdp _ range(m) range m p for p in dp for p in dp p dp for p in dp p newdp = [p for p in dp] newdp [p for p in dp] a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c = sum(1 << (int(i) - 1) for i in input().split()) c sum(1 << (int(i) - 1) for i in input().split()) sum 1 << (int(i) - 1) 1 int(i) - 1 int(i) int i 1 for bits in range(len(dp)):
        newdp[bits | c] = min(newdp[bits | c], dp[bits] + a)
     bits range(len(dp)) range len(dp) len dp newdp[bits | c] = min(newdp[bits | c], dp[bits] + a) newdp[bits | c] newdp bits | c bits c min(newdp[bits | c], dp[bits] + a) min newdp[bits | c] newdp bits | c bits c dp[bits] + a dp[bits] dp bits a dp = newdp dp newdp 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 b = map(int, input().split()) map(int, input().split()) b c = sum(1 << (int(i) - 1) for i in input().split()) sum(1 << (int(i) - 1) for i in input().split()) c dp = newdp newdp dp n, m = map(int, input().split()) map(int, input().split()) n dp = [0] + [inf] * ((1 << n) - 1) [0] + [inf] * ((1 << n) - 1) dp m = map(int, input().split()) map(int, input().split()) m inf = 10 ** 9 10 ** 9 inf newdp = [p for p in dp] [p for p in dp] newdp a, b = map(int, input().split()) map(int, input().split()) a
n, m = map(int, input().split())
inf = 10 ** 9
dp = [0] + [inf] * ((1 << n) - 1)
for _ in range(m):
    newdp = [p for p in dp]
    a, b = map(int, input().split())
    c = sum(1 << (int(i) - 1) for i in input().split())
    for bits in range(len(dp)):
        newdp[bits | c] = min(newdp[bits | c], dp[bits] + a)
    dp = newdp
print(-1 if dp[-1] == inf else dp[-1])
