import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

def digit(n, m):
    n = str(n)
    while m - len(n):
        n = '0' + n
    return n

n, m = MAP()
dp = [[inf for _ in range(2 ** n)] for _ in range(m)]
for i in range(m):
    dp[i][0] = 0
for i in range(m):
    a, b = MAP()
    c = LIST()
    arr = [1 if i + 1 in c else 0 for i in range(n)]
    cnum = 0
    for j in range(n):
        cnum += arr[j] * (2 ** (n - j - 1))
    if i == 0:
        for j in range(1, 2 ** n):
            if (cnum ^ j) & j != 0:
                continue
            dp[i][j] = a
    else:
        for j in range(1, 2 ** n):
            former = (cnum & j) ^ j
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][former] + a)
    debug(dp[i])
if dp[m - 1][2 ** n - 1] >= inf:
    print(-1)
else:
    print(dp[m - 1][2 ** n - 1]) import sys, re, os sys re os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10 from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def debug(*args):
    if debugmode:
        print(*args) debug if debugmode:
        print(*args) debugmode print(*args) print *args args *args def input(): return sys.stdin.readline().strip() input def STR(): return input() STR def INT(): return int(input()) INT def FLOAT(): return float(input()) FLOAT def MAP(): return map(int, input().split()) MAP def S_MAP(): return map(str, input().split()) S_MAP def LIST(): return list(map(int, input().split())) LIST def S_LIST(): return list(map(str, input().split())) S_LIST def lcm(a, b): return a * b // gcd(a, b) lcm a a b b sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 inf = sys.maxsize inf sys.maxsize sys maxsize mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 dx = [0, 0, 1, -1, 1, -1, -1, 1] dx [0, 0, 1, -1, 1, -1, -1, 1] 0 0 1 -1 1 -1 -1 1 dy = [1, -1, 0, 0, 1, -1, 1, -1] dy [1, -1, 0, 0, 1, -1, 1, -1] 1 -1 0 0 1 -1 1 -1 debugmode = False debugmode False def digit(n, m):
    n = str(n)
    while m - len(n):
        n = '0' + n
    return n digit n = str(n) n str(n) str n while m - len(n):
        n = '0' + n
     m - len(n) m len(n) len n n = '0' + n n '0' + n '0' n return n n n n m m n, m = MAP() n MAP() MAP m [inf for _ in range(2 ** n)] for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [inf for _ in range(2 ** n)] dp = [[inf for _ in range(2 ** n)] for _ in range(m)] dp [[inf for _ in range(2 ** n)] for _ in range(m)] for i in range(m):
    dp[i][0] = 0 i range(m) range m dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for i in range(m):
    a, b = MAP()
    c = LIST()
    arr = [1 if i + 1 in c else 0 for i in range(n)]
    cnum = 0
    for j in range(n):
        cnum += arr[j] * (2 ** (n - j - 1))
    if i == 0:
        for j in range(1, 2 ** n):
            if (cnum ^ j) & j != 0:
                continue
            dp[i][j] = a
    else:
        for j in range(1, 2 ** n):
            former = (cnum & j) ^ j
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][former] + a)
    debug(dp[i]) i range(m) range m a, b = MAP() a MAP() MAP b c = LIST() c LIST() LIST 1 if i + 1 in c else 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 1 if i + 1 in c else 0 i + 1 in c i + 1 i 1 c 1 0 arr = [1 if i + 1 in c else 0 for i in range(n)] arr [1 if i + 1 in c else 0 for i in range(n)] cnum = 0 cnum 0 for j in range(n):
        cnum += arr[j] * (2 ** (n - j - 1))
     j range(n) range n cnum += arr[j] * (2 ** (n - j - 1)) cnum arr[j] * (2 ** (n - j - 1)) arr[j] arr j 2 ** (n - j - 1) 2 n - j - 1 n - j n j 1 if i == 0:
        for j in range(1, 2 ** n):
            if (cnum ^ j) & j != 0:
                continue
            dp[i][j] = a
    else:
        for j in range(1, 2 ** n):
            former = (cnum & j) ^ j
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][former] + a)
     i == 0 i 0 for j in range(1, 2 ** n):
            if (cnum ^ j) & j != 0:
                continue
            dp[i][j] = a
     j range(1, 2 ** n) range 1 2 ** n 2 n if (cnum ^ j) & j != 0:
                continue
             (cnum ^ j) & j != 0 (cnum ^ j) & j cnum ^ j cnum j j 0 continue dp[i][j] = a dp[i][j] [i] dp i j a for j in range(1, 2 ** n):
            former = (cnum & j) ^ j
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][former] + a)
     j range(1, 2 ** n) range 1 2 ** n 2 n former = (cnum & j) ^ j former (cnum & j) ^ j cnum & j cnum j j dp[i][j] = min(dp[i - 1][j], dp[i - 1][former] + a) dp[i][j] [i] dp i j min(dp[i - 1][j], dp[i - 1][former] + a) min dp[i - 1][j] [i - 1] dp i - 1 i 1 j dp[i - 1][former] + a dp[i - 1][former] [i - 1] dp i - 1 i 1 former a debug(dp[i]) debug dp[i] dp i if dp[m - 1][2 ** n - 1] >= inf:
    print(-1)
else:
    print(dp[m - 1][2 ** n - 1]) dp[m - 1][2 ** n - 1] >= inf dp[m - 1][2 ** n - 1] [m - 1] dp m - 1 m 1 2 ** n - 1 2 ** n 2 n 1 inf print(-1) print -1 print(dp[m - 1][2 ** n - 1]) print dp[m - 1][2 ** n - 1] [m - 1] dp m - 1 m 1 2 ** n - 1 2 ** n 2 n 1 cnum = 0 0 cnum cnum += arr[j] * (2 ** (n - j - 1)) arr[j] * (2 ** (n - j - 1)) cnum b = MAP() MAP() b def LIST(): return list(map(int, input().split())) def LIST(): return list(map(int, input().split())) LIST n, m = MAP() MAP() n def INT(): return int(input()) def INT(): return int(input()) INT def STR(): return input() def STR(): return input() STR m = MAP() MAP() m debugmode = False False debugmode arr = [1 if i + 1 in c else 0 for i in range(n)] [1 if i + 1 in c else 0 for i in range(n)] arr def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input def debug(*args):
    if debugmode:
        print(*args) def debug(*args):
    if debugmode:
        print(*args) debug def S_LIST(): return list(map(str, input().split())) def S_LIST(): return list(map(str, input().split())) S_LIST def digit(n, m):
    n = str(n)
    while m - len(n):
        n = '0' + n
    return n def digit(n, m):
    n = str(n)
    while m - len(n):
        n = '0' + n
    return n digit dp = [[inf for _ in range(2 ** n)] for _ in range(m)] [[inf for _ in range(2 ** n)] for _ in range(m)] dp def S_MAP(): return map(str, input().split()) def S_MAP(): return map(str, input().split()) S_MAP c = LIST() LIST() c dy = [1, -1, 0, 0, 1, -1, 1, -1] [1, -1, 0, 0, 1, -1, 1, -1] dy mod = 10 ** 9 + 7 10 ** 9 + 7 mod inf = sys.maxsize sys.maxsize inf def MAP(): return map(int, input().split()) def MAP(): return map(int, input().split()) MAP dx = [0, 0, 1, -1, 1, -1, -1, 1] [0, 0, 1, -1, 1, -1, -1, 1] dx def FLOAT(): return float(input()) def FLOAT(): return float(input()) FLOAT a, b = MAP() MAP() a former = (cnum & j) ^ j (cnum & j) ^ j former def lcm(a, b): return a * b // gcd(a, b) def lcm(a, b): return a * b // gcd(a, b) lcm
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

def digit(n, m):
    n = str(n)
    while m - len(n):
        n = '0' + n
    return n

n, m = MAP()
dp = [[inf for _ in range(2 ** n)] for _ in range(m)]
for i in range(m):
    dp[i][0] = 0
for i in range(m):
    a, b = MAP()
    c = LIST()
    arr = [1 if i + 1 in c else 0 for i in range(n)]
    cnum = 0
    for j in range(n):
        cnum += arr[j] * (2 ** (n - j - 1))
    if i == 0:
        for j in range(1, 2 ** n):
            if (cnum ^ j) & j != 0:
                continue
            dp[i][j] = a
    else:
        for j in range(1, 2 ** n):
            former = (cnum & j) ^ j
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][former] + a)
    debug(dp[i])
if dp[m - 1][2 ** n - 1] >= inf:
    print(-1)
else:
    print(dp[m - 1][2 ** n - 1])
