import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    A = []
    C = []
    for i in range(M):
        a, _ = LI()
        bit = 0
        A.append(a)
        c = LI()
        for ix in c:
            bit = bit | 1 << (ix-1)
        C.append(bit)
    dp = [[inf for _ in range(1 << N)] for __ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1 << N):
            # use i-th key
            dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    ans = dp[M][(1 << N) - 1]
    if ans == inf:
        print(-1)
        return
    print(ans)
    return

main()
 import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools math string itertools fractions heapq collections re array bisect sys random time copy functools from collections import deque sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 inf = 10**20 inf 10**20 10 20 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 DR = [1, -1, 0, 0] DR [1, -1, 0, 0] 1 -1 0 0 DC = [0, 0, 1, -1] DC [0, 0, 1, -1] 0 0 1 -1 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x def LI(): return [int(x) for x in sys.stdin.readline().split()] LI int(x)-1 for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x)-1 int(x) int x 1 def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] LI_ float(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() float(x) float x def LF(): return [float(x) for x in sys.stdin.readline().split()] LF def LS(): return sys.stdin.readline().split() LS def I(): return int(sys.stdin.readline()) I def F(): return float(sys.stdin.readline()) F def S(): return input()
      S def main():
    N, M = LI()
    A = []
    C = []
    for i in range(M):
        a, _ = LI()
        bit = 0
        A.append(a)
        c = LI()
        for ix in c:
            bit = bit | 1 << (ix-1)
        C.append(bit)
    dp = [[inf for _ in range(1 << N)] for __ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1 << N):
            # use i-th key
            dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    ans = dp[M][(1 << N) - 1]
    if ans == inf:
        print(-1)
        return
    print(ans)
    return main N, M = LI() N LI() LI M A = [] A [] C = [] C [] for i in range(M):
        a, _ = LI()
        bit = 0
        A.append(a)
        c = LI()
        for ix in c:
            bit = bit | 1 << (ix-1)
        C.append(bit)
     i range(M) range M a, _ = LI() a LI() LI _ bit = 0 bit 0 A.append(a) A.append A append a c = LI() c LI() LI for ix in c:
            bit = bit | 1 << (ix-1)
         ix c bit = bit | 1 << (ix-1) bit bit | 1 << (ix-1) bit 1 << (ix-1) 1 ix-1 ix 1 C.append(bit) C.append C append bit [inf for _ in range(1 << N)] for __ in range(M+1) for __ in range(M+1) __ range(M+1) range M+1 M 1 for __ in range(M+1) [inf for _ in range(1 << N)] dp = [[inf for _ in range(1 << N)] for __ in range(M+1)] dp [[inf for _ in range(1 << N)] for __ in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
        for j in range(1 << N):
            # use i-th key
            dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
     i range(M) range M for j in range(1 << N):
            # use i-th key
            dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
     j range(1 << N) range 1 << N 1 N dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i]) dp[i+1][j | C[i]] [i+1] dp i+1 i 1 j | C[i] j C[i] C i min(dp[i+1][j | C[i]], dp[i][j] + A[i]) min dp[i+1][j | C[i]] [i+1] dp i+1 i 1 j | C[i] j C[i] C i dp[i][j] + A[i] dp[i][j] [i] dp i j A[i] A i 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 ans = dp[M][(1 << N) - 1] ans dp[M][(1 << N) - 1] [M] dp M (1 << N) - 1 1 << N 1 N 1 if ans == inf:
        print(-1)
        return
     ans == inf ans inf print(-1) print -1 return print(ans) print ans return main() main inf = 10**20 10**20 inf def main():
    N, M = LI()
    A = []
    C = []
    for i in range(M):
        a, _ = LI()
        bit = 0
        A.append(a)
        c = LI()
        for ix in c:
            bit = bit | 1 << (ix-1)
        C.append(bit)
    dp = [[inf for _ in range(1 << N)] for __ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1 << N):
            # use i-th key
            dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    ans = dp[M][(1 << N) - 1]
    if ans == inf:
        print(-1)
        return
    print(ans)
    return def main():
    N, M = LI()
    A = []
    C = []
    for i in range(M):
        a, _ = LI()
        bit = 0
        A.append(a)
        c = LI()
        for ix in c:
            bit = bit | 1 << (ix-1)
        C.append(bit)
    dp = [[inf for _ in range(1 << N)] for __ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1 << N):
            # use i-th key
            dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    ans = dp[M][(1 << N) - 1]
    if ans == inf:
        print(-1)
        return
    print(ans)
    return main def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI(): return [int(x) for x in sys.stdin.readline().split()] LI DC = [0, 0, 1, -1] [0, 0, 1, -1] DC def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] LI_ def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS def F(): return float(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) F mod = 10**9 + 7 10**9 + 7 mod DR = [1, -1, 0, 0] [1, -1, 0, 0] DR def LF(): return [float(x) for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] LF def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I def S(): return input()
      def S(): return input()
      S
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    A = []
    C = []
    for i in range(M):
        a, _ = LI()
        bit = 0
        A.append(a)
        c = LI()
        for ix in c:
            bit = bit | 1 << (ix-1)
        C.append(bit)
    dp = [[inf for _ in range(1 << N)] for __ in range(M+1)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1 << N):
            # use i-th key
            dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    ans = dp[M][(1 << N) - 1]
    if ans == inf:
        print(-1)
        return
    print(ans)
    return

main()

