n,m = map(int, input().split())
l = []
for _ in range(m):
    a,b = map(int, input().split())
    cl = [x-1 for x in map(int, input().split())]
    b = 0
    for i in cl:
        b |= 1<<i
    l.append([a,b])

inf = 10**9
dp = [inf]*2**n
dp[0] = 0
for x in range(2**n):
    for i in range(m):
        a,b = l[i]
        dp[x|b] = min(dp[x|b], dp[x]+a)

if dp[-1]==inf:
    print(-1)
else:
    print(dp[-1]) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l = [] l [] for _ in range(m):
    a,b = map(int, input().split())
    cl = [x-1 for x in map(int, input().split())]
    b = 0
    for i in cl:
        b |= 1<<i
    l.append([a,b]) _ range(m) range m a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b x-1 for x in map(int, input().split()) for x in map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split for x in map(int, input().split()) x-1 x 1 cl = [x-1 for x in map(int, input().split())] cl [x-1 for x in map(int, input().split())] b = 0 b 0 for i in cl:
        b |= 1<<i
     i cl b |= 1<<i b 1<<i 1 i l.append([a,b]) l.append l append [a,b] a b inf = 10**9 inf 10**9 10 9 dp = [inf]*2**n dp [inf]*2**n [inf] inf 2**n 2 n dp[0] = 0 dp[0] dp 0 0 for x in range(2**n):
    for i in range(m):
        a,b = l[i]
        dp[x|b] = min(dp[x|b], dp[x]+a) x range(2**n) range 2**n 2 n for i in range(m):
        a,b = l[i]
        dp[x|b] = min(dp[x|b], dp[x]+a) i range(m) range m a,b = l[i] a l[i] l i b dp[x|b] = min(dp[x|b], dp[x]+a) dp[x|b] dp x|b x b min(dp[x|b], dp[x]+a) min dp[x|b] dp x|b x b dp[x]+a dp[x] dp x a if dp[-1]==inf:
    print(-1)
else:
    print(dp[-1]) dp[-1]==inf dp[-1] dp -1 inf print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 b = 0 0 b a,b = l[i] l[i] a b |= 1<<i 1<<i b a,b = map(int, input().split()) map(int, input().split()) a dp = [inf]*2**n [inf]*2**n dp b = map(int, input().split()) map(int, input().split()) b cl = [x-1 for x in map(int, input().split())] [x-1 for x in map(int, input().split())] cl l = [] [] l inf = 10**9 10**9 inf n,m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m b = l[i] l[i] b
n,m = map(int, input().split())
l = []
for _ in range(m):
    a,b = map(int, input().split())
    cl = [x-1 for x in map(int, input().split())]
    b = 0
    for i in cl:
        b |= 1<<i
    l.append([a,b])

inf = 10**9
dp = [inf]*2**n
dp[0] = 0
for x in range(2**n):
    for i in range(m):
        a,b = l[i]
        dp[x|b] = min(dp[x|b], dp[x]+a)

if dp[-1]==inf:
    print(-1)
else:
    print(dp[-1])