#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N, M = map(int, input().split())
keys = []
for _ in range(M):
    a, b = map(int, input().split())
    bits = 0
    for i in map(int, input().split()):
        bits = bits | (1 << (i - 1))
    keys.append([a, bits])

dp = [[INF] * (2 ** N + 10) for _ in range(M + 10)]
dp[0][0] = 0

for i in range(M):
    for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | keys[i][1]] = min(dp[i + 1][j | keys[i][1]], dp[i][j] + keys[i][0])
print(dp[M][2 ** N - 1] if dp[M][2 ** N - 1] != INF else -1) import sys sys import math math import string string import collections collections import fractions fractions import random random from operator import itemgetter import itertools itertools from collections import deque import copy copy import heapq heapq import bisect bisect MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = 10 ** 18 INF 10 ** 18 10 18 input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M keys = [] keys [] for _ in range(M):
    a, b = map(int, input().split())
    bits = 0
    for i in map(int, input().split()):
        bits = bits | (1 << (i - 1))
    keys.append([a, bits]) _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b bits = 0 bits 0 for i in map(int, input().split()):
        bits = bits | (1 << (i - 1))
     i map(int, input().split()) map int input().split() ().split () input split bits = bits | (1 << (i - 1)) bits bits | (1 << (i - 1)) bits 1 << (i - 1) 1 i - 1 i 1 keys.append([a, bits]) keys.append keys append [a, bits] a bits [INF] * (2 ** N + 10) for _ in range(M + 10) for _ in range(M + 10) _ range(M + 10) range M + 10 M 10 for _ in range(M + 10) [INF] * (2 ** N + 10) [INF] INF 2 ** N + 10 2 ** N 2 N 10 dp = [[INF] * (2 ** N + 10) for _ in range(M + 10)] dp [[INF] * (2 ** N + 10) for _ in range(M + 10)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | keys[i][1]] = min(dp[i + 1][j | keys[i][1]], dp[i][j] + keys[i][0]) i range(M) range M for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | keys[i][1]] = min(dp[i + 1][j | keys[i][1]], dp[i][j] + keys[i][0]) j range(2 ** N) range 2 ** N 2 N dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) dp[i + 1][j] [i + 1] dp i + 1 i 1 j min(dp[i + 1][j], dp[i][j]) min dp[i + 1][j] [i + 1] dp i + 1 i 1 j dp[i][j] [i] dp i j dp[i + 1][j | keys[i][1]] = min(dp[i + 1][j | keys[i][1]], dp[i][j] + keys[i][0]) dp[i + 1][j | keys[i][1]] [i + 1] dp i + 1 i 1 j | keys[i][1] j keys[i][1] [i] keys i 1 min(dp[i + 1][j | keys[i][1]], dp[i][j] + keys[i][0]) min dp[i + 1][j | keys[i][1]] [i + 1] dp i + 1 i 1 j | keys[i][1] j keys[i][1] [i] keys i 1 dp[i][j] + keys[i][0] dp[i][j] [i] dp i j keys[i][0] [i] keys i 0 print(dp[M][2 ** N - 1] if dp[M][2 ** N - 1] != INF else -1) print dp[M][2 ** N - 1] if dp[M][2 ** N - 1] != INF else -1 dp[M][2 ** N - 1] != INF dp[M][2 ** N - 1] [M] dp M 2 ** N - 1 2 ** N 2 N 1 INF dp[M][2 ** N - 1] [M] dp M 2 ** N - 1 2 ** N 2 N 1 -1 MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N bits = bits | (1 << (i - 1)) bits | (1 << (i - 1)) bits dp = [[INF] * (2 ** N + 10) for _ in range(M + 10)] [[INF] * (2 ** N + 10) for _ in range(M + 10)] dp b = map(int, input().split()) map(int, input().split()) b keys = [] [] keys INF = 10 ** 18 10 ** 18 INF a, b = map(int, input().split()) map(int, input().split()) a bits = 0 0 bits
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N, M = map(int, input().split())
keys = []
for _ in range(M):
    a, b = map(int, input().split())
    bits = 0
    for i in map(int, input().split()):
        bits = bits | (1 << (i - 1))
    keys.append([a, bits])

dp = [[INF] * (2 ** N + 10) for _ in range(M + 10)]
dp[0][0] = 0

for i in range(M):
    for j in range(2 ** N):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        dp[i + 1][j | keys[i][1]] = min(dp[i + 1][j | keys[i][1]], dp[i][j] + keys[i][0])
print(dp[M][2 ** N - 1] if dp[M][2 ** N - 1] != INF else -1)