from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

def unset_nth_bit(S, j):
    # Sの右からj bit目を0にする
    return S & ~(1 << j)

def set_nth_bit(S, j):
    # Sの右からj bit目を1にする
    return S | (1 << j)

def bit(S, j):
    # Sの右からj bit目(0-indexed)
    return (S>>j)&1

N, M = map(int, input().split())

a = []
c = []
for i in range(M):
    p, q = map(int, input().split())
    a.append(p)
    c.append(list(map(int, input().split())))

dp = [[INF for j in range(1<<N)] for i in range(M+1)]
dp[0][0] = 0

for i in range(M):
    for S in range(1<<N):
        SS = S
        for cc in c[i]:
            SS = set_nth_bit(SS, cc-1)
        dp[i+1][SS] = min(dp[i+1][SS], dp[i][S] + a[i])
        dp[i+1][S] = min(dp[i+1][S], dp[i][S])

if dp[M][(1<<N)-1] == INF:
    print(-1)
else:
    print(dp[M][(1<<N)-1]) from sys import stdin import sys sys import math math from functools import reduce import functools functools import itertools itertools from collections import deque,Counter,defaultdict from operator import mul import copy copy import heapq heapq sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 INF = 10**18 INF 10**18 10 18 import bisect bisect import statistics statistics mod = 10**9+7 mod 10**9+7 10**9 10 9 7 def unset_nth_bit(S, j):
    # Sの右からj bit目を0にする
    return S & ~(1 << j) unset_nth_bit return S & ~(1 << j) S & ~(1 << j) S ~(1 << j) 1 << j 1 j S S j j def set_nth_bit(S, j):
    # Sの右からj bit目を1にする
    return S | (1 << j) set_nth_bit return S | (1 << j) S | (1 << j) S 1 << j 1 j S S j j def bit(S, j):
    # Sの右からj bit目(0-indexed)
    return (S>>j)&1 bit return (S>>j)&1 (S>>j)&1 S>>j S j 1 S S j j N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M a = [] a [] c = [] c [] for i in range(M):
    p, q = map(int, input().split())
    a.append(p)
    c.append(list(map(int, input().split()))) i range(M) range M p, q = map(int, input().split()) p map(int, input().split()) map int input().split() ().split () input split q a.append(p) a.append a append p c.append(list(map(int, input().split()))) c.append c append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split [INF for j in range(1<<N)] for i in range(M+1) for i in range(M+1) i range(M+1) range M+1 M 1 for i in range(M+1) [INF for j in range(1<<N)] dp = [[INF for j in range(1<<N)] for i in range(M+1)] dp [[INF for j in range(1<<N)] for i in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    for S in range(1<<N):
        SS = S
        for cc in c[i]:
            SS = set_nth_bit(SS, cc-1)
        dp[i+1][SS] = min(dp[i+1][SS], dp[i][S] + a[i])
        dp[i+1][S] = min(dp[i+1][S], dp[i][S]) i range(M) range M for S in range(1<<N):
        SS = S
        for cc in c[i]:
            SS = set_nth_bit(SS, cc-1)
        dp[i+1][SS] = min(dp[i+1][SS], dp[i][S] + a[i])
        dp[i+1][S] = min(dp[i+1][S], dp[i][S]) S range(1<<N) range 1<<N 1 N SS = S SS S for cc in c[i]:
            SS = set_nth_bit(SS, cc-1)
         cc c[i] c i SS = set_nth_bit(SS, cc-1) SS set_nth_bit(SS, cc-1) set_nth_bit SS cc-1 cc 1 dp[i+1][SS] = min(dp[i+1][SS], dp[i][S] + a[i]) dp[i+1][SS] [i+1] dp i+1 i 1 SS min(dp[i+1][SS], dp[i][S] + a[i]) min dp[i+1][SS] [i+1] dp i+1 i 1 SS dp[i][S] + a[i] dp[i][S] [i] dp i S a[i] a i dp[i+1][S] = min(dp[i+1][S], dp[i][S]) dp[i+1][S] [i+1] dp i+1 i 1 S min(dp[i+1][S], dp[i][S]) min dp[i+1][S] [i+1] dp i+1 i 1 S dp[i][S] [i] dp i S if dp[M][(1<<N)-1] == INF:
    print(-1)
else:
    print(dp[M][(1<<N)-1]) dp[M][(1<<N)-1] == INF dp[M][(1<<N)-1] [M] dp M (1<<N)-1 1<<N 1 N 1 INF print(-1) print -1 print(dp[M][(1<<N)-1]) print dp[M][(1<<N)-1] [M] dp M (1<<N)-1 1<<N 1 N 1 q = map(int, input().split()) map(int, input().split()) q p, q = map(int, input().split()) map(int, input().split()) p def set_nth_bit(S, j):
    # Sの右からj bit目を1にする
    return S | (1 << j) def set_nth_bit(S, j):
    # Sの右からj bit目を1にする
    return S | (1 << j) set_nth_bit def unset_nth_bit(S, j):
    # Sの右からj bit目を0にする
    return S & ~(1 << j) def unset_nth_bit(S, j):
    # Sの右からj bit目を0にする
    return S & ~(1 << j) unset_nth_bit a = [] [] a def bit(S, j):
    # Sの右からj bit目(0-indexed)
    return (S>>j)&1 def bit(S, j):
    # Sの右からj bit目(0-indexed)
    return (S>>j)&1 bit c = [] [] c dp = [[INF for j in range(1<<N)] for i in range(M+1)] [[INF for j in range(1<<N)] for i in range(M+1)] dp SS = set_nth_bit(SS, cc-1) set_nth_bit(SS, cc-1) SS SS = S S SS mod = 10**9+7 10**9+7 mod N, M = map(int, input().split()) map(int, input().split()) N INF = 10**18 10**18 INF M = map(int, input().split()) map(int, input().split()) M
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

def unset_nth_bit(S, j):
    # Sの右からj bit目を0にする
    return S & ~(1 << j)

def set_nth_bit(S, j):
    # Sの右からj bit目を1にする
    return S | (1 << j)

def bit(S, j):
    # Sの右からj bit目(0-indexed)
    return (S>>j)&1

N, M = map(int, input().split())

a = []
c = []
for i in range(M):
    p, q = map(int, input().split())
    a.append(p)
    c.append(list(map(int, input().split())))

dp = [[INF for j in range(1<<N)] for i in range(M+1)]
dp[0][0] = 0

for i in range(M):
    for S in range(1<<N):
        SS = S
        for cc in c[i]:
            SS = set_nth_bit(SS, cc-1)
        dp[i+1][SS] = min(dp[i+1][SS], dp[i][S] + a[i])
        dp[i+1][S] = min(dp[i+1][S], dp[i][S])

if dp[M][(1<<N)-1] == INF:
    print(-1)
else:
    print(dp[M][(1<<N)-1])