N, M = map(int, input().split())
X = []
Y = []
for _ in range(M):
    X.append(list(map(int, input().split())))
    
    tmp = 0
    for i in list(map(int, input().split())):
        tmp += 2 ** (i - 1)
    Y.append(tmp)

inf = 10 ** 9 + 7
dp = [[inf] * (2 ** N) for _ in range(M + 1)]
dp[0][0] = 0
for i in range(M):
    for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | Y[i]] = min(dp[i + 1][j | Y[i]],
                                  dp[i][j] + X[i][0])

ans = min(dp[i][-1] for i in range(M + 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 X = [] X [] Y = [] Y [] for _ in range(M):
    X.append(list(map(int, input().split())))
    
    tmp = 0
    for i in list(map(int, input().split())):
        tmp += 2 ** (i - 1)
    Y.append(tmp) _ range(M) range M X.append(list(map(int, input().split()))) X.append X append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split tmp = 0 tmp 0 for i in list(map(int, input().split())):
        tmp += 2 ** (i - 1)
     i list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split tmp += 2 ** (i - 1) tmp 2 ** (i - 1) 2 i - 1 i 1 Y.append(tmp) Y.append Y append tmp inf = 10 ** 9 + 7 inf 10 ** 9 + 7 10 ** 9 10 9 7 [inf] * (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) [inf] * (2 ** N) [inf] inf 2 ** N 2 N dp = [[inf] * (2 ** N) for _ in range(M + 1)] dp [[inf] * (2 ** 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(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | Y[i]] = min(dp[i + 1][j | Y[i]],
                                  dp[i][j] + X[i][0]) i range(M) range M for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | Y[i]] = min(dp[i + 1][j | Y[i]],
                                  dp[i][j] + X[i][0]) j range(2 ** N) range 2 ** N 2 N 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][j | Y[i]] = min(dp[i + 1][j | Y[i]],
                                  dp[i][j] + X[i][0]) dp[i + 1][j | Y[i]] [i + 1] dp i + 1 i 1 j | Y[i] j Y[i] Y i min(dp[i + 1][j | Y[i]],
                                  dp[i][j] + X[i][0]) min dp[i + 1][j | Y[i]] [i + 1] dp i + 1 i 1 j | Y[i] j Y[i] Y i dp[i][j] + X[i][0] dp[i][j] [i] dp i j X[i][0] [i] X i 0 ans = min(dp[i][-1] for i in range(M + 1)) ans min(dp[i][-1] for i in range(M + 1)) min dp[i][-1] [i] dp i -1 print(ans if ans < inf else -1) print ans if ans < inf else -1 ans < inf ans inf ans -1 Y = [] [] Y M = map(int, input().split()) map(int, input().split()) M dp = [[inf] * (2 ** N) for _ in range(M + 1)] [[inf] * (2 ** N) for _ in range(M + 1)] dp tmp += 2 ** (i - 1) 2 ** (i - 1) tmp ans = min(dp[i][-1] for i in range(M + 1)) min(dp[i][-1] for i in range(M + 1)) ans inf = 10 ** 9 + 7 10 ** 9 + 7 inf X = [] [] X N, M = map(int, input().split()) map(int, input().split()) N tmp = 0 0 tmp
N, M = map(int, input().split())
X = []
Y = []
for _ in range(M):
    X.append(list(map(int, input().split())))
    
    tmp = 0
    for i in list(map(int, input().split())):
        tmp += 2 ** (i - 1)
    Y.append(tmp)

inf = 10 ** 9 + 7
dp = [[inf] * (2 ** N) for _ in range(M + 1)]
dp[0][0] = 0
for i in range(M):
    for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | Y[i]] = min(dp[i + 1][j | Y[i]],
                                  dp[i][j] + X[i][0])

ans = min(dp[i][-1] for i in range(M + 1))
print(ans if ans < inf else -1)

