n , m = map(int,input().split())
kagi = []
for i in range(m):
    a , b = map(int,input().split())
    c = list(map(int,input().split()))
    k = 0
    for j in c:
        k += 1 << (j-1)
    kagi.append((a,k))
INF = 10 ** 9
dp = [[INF for i in range(m+1)] for i in range(2**n)]
dp[0] = [0 for i in range(m+1)]
for i in range(2**n):
    for j in range(1,m+1):
        dp[i][j] = min(dp[i][j],dp[i][j-1])
        t = i | kagi[j-1][1]
        dp[t][j] = min(dp[t][j],dp[i][j]+kagi[j-1][0])
print(dp[2**n-1][m] if dp[2**n-1][m] != INF else -1) n , m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m kagi = [] kagi [] for i in range(m):
    a , b = map(int,input().split())
    c = list(map(int,input().split()))
    k = 0
    for j in c:
        k += 1 << (j-1)
    kagi.append((a,k)) i range(m) range m 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 k = 0 k 0 for j in c:
        k += 1 << (j-1)
     j c k += 1 << (j-1) k 1 << (j-1) 1 j-1 j 1 kagi.append((a,k)) kagi.append kagi append (a,k) a k INF = 10 ** 9 INF 10 ** 9 10 9 [INF for i in range(m+1)] for i in range(2**n) for i in range(2**n) i range(2**n) range 2**n 2 n for i in range(2**n) [INF for i in range(m+1)] dp = [[INF for i in range(m+1)] for i in range(2**n)] dp [[INF for i in range(m+1)] for i in range(2**n)] 0 for i in range(m+1) for i in range(m+1) i range(m+1) range m+1 m 1 for i in range(m+1) 0 dp[0] = [0 for i in range(m+1)] dp[0] dp 0 [0 for i in range(m+1)] for i in range(2**n):
    for j in range(1,m+1):
        dp[i][j] = min(dp[i][j],dp[i][j-1])
        t = i | kagi[j-1][1]
        dp[t][j] = min(dp[t][j],dp[i][j]+kagi[j-1][0]) i range(2**n) range 2**n 2 n for j in range(1,m+1):
        dp[i][j] = min(dp[i][j],dp[i][j-1])
        t = i | kagi[j-1][1]
        dp[t][j] = min(dp[t][j],dp[i][j]+kagi[j-1][0]) j range(1,m+1) range 1 m+1 m 1 dp[i][j] = min(dp[i][j],dp[i][j-1]) dp[i][j] [i] dp i j min(dp[i][j],dp[i][j-1]) min dp[i][j] [i] dp i j dp[i][j-1] [i] dp i j-1 j 1 t = i | kagi[j-1][1] t i | kagi[j-1][1] i kagi[j-1][1] [j-1] kagi j-1 j 1 1 dp[t][j] = min(dp[t][j],dp[i][j]+kagi[j-1][0]) dp[t][j] [t] dp t j min(dp[t][j],dp[i][j]+kagi[j-1][0]) min dp[t][j] [t] dp t j dp[i][j]+kagi[j-1][0] dp[i][j] [i] dp i j kagi[j-1][0] [j-1] kagi j-1 j 1 0 print(dp[2**n-1][m] if dp[2**n-1][m] != INF else -1) print dp[2**n-1][m] if dp[2**n-1][m] != INF else -1 dp[2**n-1][m] != INF dp[2**n-1][m] [2**n-1] dp 2**n-1 2**n 2 n 1 m INF dp[2**n-1][m] [2**n-1] dp 2**n-1 2**n 2 n 1 m -1 kagi = [] [] kagi INF = 10 ** 9 10 ** 9 INF a , b = map(int,input().split()) map(int,input().split()) a dp = [[INF for i in range(m+1)] for i in range(2**n)] [[INF for i in range(m+1)] for i in range(2**n)] dp n , m = map(int,input().split()) map(int,input().split()) n c = list(map(int,input().split())) list(map(int,input().split())) c k += 1 << (j-1) 1 << (j-1) k m = map(int,input().split()) map(int,input().split()) m k = 0 0 k t = i | kagi[j-1][1] i | kagi[j-1][1] t b = map(int,input().split()) map(int,input().split()) b
n , m = map(int,input().split())
kagi = []
for i in range(m):
    a , b = map(int,input().split())
    c = list(map(int,input().split()))
    k = 0
    for j in c:
        k += 1 << (j-1)
    kagi.append((a,k))
INF = 10 ** 9
dp = [[INF for i in range(m+1)] for i in range(2**n)]
dp[0] = [0 for i in range(m+1)]
for i in range(2**n):
    for j in range(1,m+1):
        dp[i][j] = min(dp[i][j],dp[i][j-1])
        t = i | kagi[j-1][1]
        dp[t][j] = min(dp[t][j],dp[i][j]+kagi[j-1][0])
print(dp[2**n-1][m] if dp[2**n-1][m] != INF else -1)