n, m = map(int, input().split())
c = []
a = []
for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    a.append(ai)
    c.append(sum(ci))

INF = 100 ** 18
dp = [INF] * (2**n)
dp[0] = 0
for i in range(m):
    for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i])

ans = dp[2**n-1]
if ans == INF:
    print(-1)
    exit()
print(ans)
 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m c = [] c [] a = [] a [] for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    a.append(ai)
    c.append(sum(ci)) _ range(m) range m ai, bi = map(int, input().split()) ai map(int, input().split()) map int input().split() ().split () input split bi ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split())) ci list(map(lambda x: 2 ** (int(x) - 1) , input().split())) list map(lambda x: 2 ** (int(x) - 1) , input().split()) map lambda x: 2 ** (int(x) - 1) 2 ** (int(x) - 1) 2 int(x) - 1 int(x) int x 1 x input().split() ().split () input split a.append(ai) a.append a append ai c.append(sum(ci)) c.append c append sum(ci) sum ci INF = 100 ** 18 INF 100 ** 18 100 18 dp = [INF] * (2**n) dp [INF] * (2**n) [INF] INF 2**n 2 n dp[0] = 0 dp[0] dp 0 0 for i in range(m):
    for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i]) i range(m) range m for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i]) j range(0, 2**n) range 0 2**n 2 n dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i]) dp[j | c[i]] dp j | c[i] j c[i] c i min(dp[j | c[i]], dp[j] + a[i]) min dp[j | c[i]] dp j | c[i] j c[i] c i dp[j] + a[i] dp[j] dp j a[i] a i ans = dp[2**n-1] ans dp[2**n-1] dp 2**n-1 2**n 2 n 1 if ans == INF:
    print(-1)
    exit() ans == INF ans INF print(-1) print -1 exit() exit print(ans) print ans ai, bi = map(int, input().split()) map(int, input().split()) ai m = map(int, input().split()) map(int, input().split()) m c = [] [] c n, m = map(int, input().split()) map(int, input().split()) n INF = 100 ** 18 100 ** 18 INF dp = [INF] * (2**n) [INF] * (2**n) dp ans = dp[2**n-1] dp[2**n-1] ans a = [] [] a bi = map(int, input().split()) map(int, input().split()) bi ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split())) list(map(lambda x: 2 ** (int(x) - 1) , input().split())) ci
n, m = map(int, input().split())
c = []
a = []
for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    a.append(ai)
    c.append(sum(ci))

INF = 100 ** 18
dp = [INF] * (2**n)
dp[0] = 0
for i in range(m):
    for j in range(0, 2**n):
        dp[j | c[i]] = min(dp[j | c[i]], dp[j] + a[i])

ans = dp[2**n-1]
if ans == INF:
    print(-1)
    exit()
print(ans)

