n, m = map(int, input().split())
l = pow(2, n)
inf = pow(10, 7)
pow2 = [pow(2, i) for i in range(n)]
dp = [[inf] * l for _ in range(m + 1)]
dp[0][0] = 0
for i in range(1, m + 1):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for j in c:
        bit += pow2[j - 1]
    for j in range(l):
        k = j | bit
        dp[i][j] = min(dp[i][j], dp[i - 1][j])
        dp[i][k] = min(dp[i][k], dp[i - 1][j] + a)
print(dp[m][l - 1] if not dp[m][l - 1] == inf else -1) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l = pow(2, n) l pow(2, n) pow 2 n inf = pow(10, 7) inf pow(10, 7) pow 10 7 pow(2, i) for i in range(n) for i in range(n) i range(n) range n for i in range(n) pow(2, i) pow 2 i pow2 = [pow(2, i) for i in range(n)] pow2 [pow(2, i) for i in range(n)] [inf] * l for _ in range(m + 1) for _ in range(m + 1) _ range(m + 1) range m + 1 m 1 for _ in range(m + 1) [inf] * l [inf] inf l dp = [[inf] * l for _ in range(m + 1)] dp [[inf] * l for _ in range(m + 1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(1, m + 1):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for j in c:
        bit += pow2[j - 1]
    for j in range(l):
        k = j | bit
        dp[i][j] = min(dp[i][j], dp[i - 1][j])
        dp[i][k] = min(dp[i][k], dp[i - 1][j] + a) i range(1, m + 1) range 1 m + 1 m 1 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 bit = 0 bit 0 for j in c:
        bit += pow2[j - 1]
     j c bit += pow2[j - 1] bit pow2[j - 1] pow2 j - 1 j 1 for j in range(l):
        k = j | bit
        dp[i][j] = min(dp[i][j], dp[i - 1][j])
        dp[i][k] = min(dp[i][k], dp[i - 1][j] + a) j range(l) range l k = j | bit k j | bit j bit dp[i][j] = min(dp[i][j], dp[i - 1][j]) dp[i][j] [i] dp i 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 dp[i][k] = min(dp[i][k], dp[i - 1][j] + a) dp[i][k] [i] dp i k min(dp[i][k], dp[i - 1][j] + a) min dp[i][k] [i] dp i k dp[i - 1][j] + a dp[i - 1][j] [i - 1] dp i - 1 i 1 j a print(dp[m][l - 1] if not dp[m][l - 1] == inf else -1) print dp[m][l - 1] if not dp[m][l - 1] == inf else -1 not dp[m][l - 1] == inf dp[m][l - 1] == inf dp[m][l - 1] [m] dp m l - 1 l 1 inf dp[m][l - 1] [m] dp m l - 1 l 1 -1 inf = pow(10, 7) pow(10, 7) inf pow2 = [pow(2, i) for i in range(n)] [pow(2, i) for i in range(n)] pow2 c = list(map(int, input().split())) list(map(int, input().split())) c k = j | bit j | bit k m = map(int, input().split()) map(int, input().split()) m l = pow(2, n) pow(2, n) l a, b = map(int, input().split()) map(int, input().split()) a bit += pow2[j - 1] pow2[j - 1] bit b = map(int, input().split()) map(int, input().split()) b bit = 0 0 bit dp = [[inf] * l for _ in range(m + 1)] [[inf] * l for _ in range(m + 1)] dp n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
l = pow(2, n)
inf = pow(10, 7)
pow2 = [pow(2, i) for i in range(n)]
dp = [[inf] * l for _ in range(m + 1)]
dp[0][0] = 0
for i in range(1, m + 1):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for j in c:
        bit += pow2[j - 1]
    for j in range(l):
        k = j | bit
        dp[i][j] = min(dp[i][j], dp[i - 1][j])
        dp[i][k] = min(dp[i][k], dp[i - 1][j] + a)
print(dp[m][l - 1] if not dp[m][l - 1] == inf else -1)