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

INF = 100 ** 18
dp = [INF] * (2**n)
dp[0] = 0
for ai, ci in ac:
    for j in range(0, 2**n):
        dp[j | ci] = min(dp[j | ci], dp[j] + ai)

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 ac = [] ac [] for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    ac.append((ai, 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 ac.append((ai, sum(ci))) ac.append ac append (ai, sum(ci)) ai 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 ai, ci in ac:
    for j in range(0, 2**n):
        dp[j | ci] = min(dp[j | ci], dp[j] + ai) ai ci ac for j in range(0, 2**n):
        dp[j | ci] = min(dp[j | ci], dp[j] + ai) j range(0, 2**n) range 0 2**n 2 n dp[j | ci] = min(dp[j | ci], dp[j] + ai) dp[j | ci] dp j | ci j ci min(dp[j | ci], dp[j] + ai) min dp[j | ci] dp j | ci j ci dp[j] + ai dp[j] dp j ai 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 ans = dp[2**n-1] dp[2**n-1] ans ai, bi = map(int, input().split()) map(int, input().split()) ai INF = 100 ** 18 100 ** 18 INF ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split())) list(map(lambda x: 2 ** (int(x) - 1) , input().split())) ci m = map(int, input().split()) map(int, input().split()) m ac = [] [] ac bi = map(int, input().split()) map(int, input().split()) bi n, m = map(int, input().split()) map(int, input().split()) n dp = [INF] * (2**n) [INF] * (2**n) dp
n, m = map(int, input().split())
ac = []
for _ in range(m):
    ai, bi = map(int, input().split())
    ci = list(map(lambda x: 2 ** (int(x) - 1) , input().split()))
    ac.append((ai, sum(ci)))

INF = 100 ** 18
dp = [INF] * (2**n)
dp[0] = 0
for ai, ci in ac:
    for j in range(0, 2**n):
        dp[j | ci] = min(dp[j | ci], dp[j] + ai)

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

