n, m = map(int, input().split())
r = [2**i for i in range(n+1)]

price = [0] * m
mask = [0] * m
for i in range(m):
    a, b = map(int, input().split())
    for box in map(int, input().split()):
        mask[i] += r[box-1]
    price[i] = a


inf = 10**9
dp = [[inf] * (1 << n) for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for j in range(1 << n):
        dp[i+1][j | mask[i]] = min(
            dp[i][j] + price[i],
            dp[i+1][j | mask[i]]
        )
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])

ans = dp[m][(1 << n) - 1]
if ans == inf:
    print(-1)
else:
    print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m 2**i for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) 2**i 2 i r = [2**i for i in range(n+1)] r [2**i for i in range(n+1)] price = [0] * m price [0] * m [0] 0 m mask = [0] * m mask [0] * m [0] 0 m for i in range(m):
    a, b = map(int, input().split())
    for box in map(int, input().split()):
        mask[i] += r[box-1]
    price[i] = a i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b for box in map(int, input().split()):
        mask[i] += r[box-1]
     box map(int, input().split()) map int input().split() ().split () input split mask[i] += r[box-1] mask[i] mask i r[box-1] r box-1 box 1 price[i] = a price[i] price i a inf = 10**9 inf 10**9 10 9 [inf] * (1 << n) for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [inf] * (1 << n) [inf] inf 1 << n 1 n dp = [[inf] * (1 << n) for _ in range(m+1)] dp [[inf] * (1 << n) for _ in range(m+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    for j in range(1 << n):
        dp[i+1][j | mask[i]] = min(
            dp[i][j] + price[i],
            dp[i+1][j | mask[i]]
        )
        dp[i+1][j] = min(dp[i][j], dp[i+1][j]) i range(m) range m for j in range(1 << n):
        dp[i+1][j | mask[i]] = min(
            dp[i][j] + price[i],
            dp[i+1][j | mask[i]]
        )
        dp[i+1][j] = min(dp[i][j], dp[i+1][j]) j range(1 << n) range 1 << n 1 n dp[i+1][j | mask[i]] = min(
            dp[i][j] + price[i],
            dp[i+1][j | mask[i]]
        ) dp[i+1][j | mask[i]] [i+1] dp i+1 i 1 j | mask[i] j mask[i] mask i min(
            dp[i][j] + price[i],
            dp[i+1][j | mask[i]]
        ) min dp[i][j] + price[i] dp[i][j] [i] dp i j price[i] price i dp[i+1][j | mask[i]] [i+1] dp i+1 i 1 j | mask[i] j mask[i] mask i dp[i+1][j] = min(dp[i][j], dp[i+1][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i][j], dp[i+1][j]) min dp[i][j] [i] dp i j dp[i+1][j] [i+1] dp i+1 i 1 j ans = dp[m][(1 << n) - 1] ans dp[m][(1 << n) - 1] [m] dp m (1 << n) - 1 1 << n 1 n 1 if ans == inf:
    print(-1)
else:
    print(ans) ans == inf ans inf print(-1) print -1 print(ans) print ans mask = [0] * m [0] * m mask b = map(int, input().split()) map(int, input().split()) b inf = 10**9 10**9 inf ans = dp[m][(1 << n) - 1] dp[m][(1 << n) - 1] ans a, b = map(int, input().split()) map(int, input().split()) a r = [2**i for i in range(n+1)] [2**i for i in range(n+1)] r price = [0] * m [0] * m price n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m dp = [[inf] * (1 << n) for _ in range(m+1)] [[inf] * (1 << n) for _ in range(m+1)] dp
n, m = map(int, input().split())
r = [2**i for i in range(n+1)]

price = [0] * m
mask = [0] * m
for i in range(m):
    a, b = map(int, input().split())
    for box in map(int, input().split()):
        mask[i] += r[box-1]
    price[i] = a


inf = 10**9
dp = [[inf] * (1 << n) for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for j in range(1 << n):
        dp[i+1][j | mask[i]] = min(
            dp[i][j] + price[i],
            dp[i+1][j | mask[i]]
        )
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])

ans = dp[m][(1 << n) - 1]
if ans == inf:
    print(-1)
else:
    print(ans)
