#!/usr/bin python3
# -*- coding: utf-8 -*-

INF = 10**6

n, m = map(int, input().split())
dp = [INF] * (2**n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().split())
    bit = ['0'] * n
    for x in set(map(int, input().split())):
        bit[x-1] = '1'
    bit = int(''.join(bit), 2)
    for j in range(2**n-1, -1, -1):
        dp[j|bit] = min(dp[j|bit], a + dp[j])
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1]) INF = 10**6 INF 10**6 10 6 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m 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):
    a, b = map(int, input().split())
    bit = ['0'] * n
    for x in set(map(int, input().split())):
        bit[x-1] = '1'
    bit = int(''.join(bit), 2)
    for j in range(2**n-1, -1, -1):
        dp[j|bit] = min(dp[j|bit], a + dp[j]) i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b bit = ['0'] * n bit ['0'] * n ['0'] '0' n for x in set(map(int, input().split())):
        bit[x-1] = '1'
     x set(map(int, input().split())) set map(int, input().split()) map int input().split() ().split () input split bit[x-1] = '1' bit[x-1] bit x-1 x 1 '1' bit = int(''.join(bit), 2) bit int(''.join(bit), 2) int ''.join(bit) ''.join '' join bit 2 for j in range(2**n-1, -1, -1):
        dp[j|bit] = min(dp[j|bit], a + dp[j]) j range(2**n-1, -1, -1) range 2**n-1 2**n 2 n 1 -1 -1 dp[j|bit] = min(dp[j|bit], a + dp[j]) dp[j|bit] dp j|bit j bit min(dp[j|bit], a + dp[j]) min dp[j|bit] dp j|bit j bit a + dp[j] a dp[j] dp j 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 INF = 10**6 10**6 INF bit = int(''.join(bit), 2) int(''.join(bit), 2) bit m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n dp = [INF] * (2**n) [INF] * (2**n) dp b = map(int, input().split()) map(int, input().split()) b bit = ['0'] * n ['0'] * n bit a, b = map(int, input().split()) map(int, input().split()) a
#!/usr/bin python3
# -*- coding: utf-8 -*-

INF = 10**6

n, m = map(int, input().split())
dp = [INF] * (2**n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().split())
    bit = ['0'] * n
    for x in set(map(int, input().split())):
        bit[x-1] = '1'
    bit = int(''.join(bit), 2)
    for j in range(2**n-1, -1, -1):
        dp[j|bit] = min(dp[j|bit], a + dp[j])
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])
