#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n,m=map(int,input().split())
k=2**n
inf=10**7
d=[[inf]*k for _ in range(m+1)]
for i in range(m+1):
  d[i][0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    res=0
    for x in c:
        res+=2**(x-1)
    for j in range(2**n):
        jx=j|res
        d[i+1][j]=min(d[i+1][j],d[i][j])
        d[i+1][jx]=min(d[i][jx],d[i][j]+a,d[i+1][jx])
if d[-1][-1]==10**7:
  print(-1)
else:
  print(d[-1][-1]) import math math import itertools itertools from collections import deque from collections import Counter import heapq heapq from fractions  import gcd n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m k=2**n k 2**n 2 n inf=10**7 inf 10**7 10 7 [inf]*k for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [inf]*k [inf] inf k d=[[inf]*k for _ in range(m+1)] d [[inf]*k for _ in range(m+1)] for i in range(m+1):
  d[i][0]=0 i range(m+1) range m+1 m 1 d[i][0]=0 d[i][0] [i] d i 0 0 for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    res=0
    for x in c:
        res+=2**(x-1)
    for j in range(2**n):
        jx=j|res
        d[i+1][j]=min(d[i+1][j],d[i][j])
        d[i+1][jx]=min(d[i][jx],d[i][j]+a,d[i+1][jx]) i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c=list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split res=0 res 0 for x in c:
        res+=2**(x-1)
     x c res+=2**(x-1) res 2**(x-1) 2 x-1 x 1 for j in range(2**n):
        jx=j|res
        d[i+1][j]=min(d[i+1][j],d[i][j])
        d[i+1][jx]=min(d[i][jx],d[i][j]+a,d[i+1][jx]) j range(2**n) range 2**n 2 n jx=j|res jx j|res j res d[i+1][j]=min(d[i+1][j],d[i][j]) d[i+1][j] [i+1] d i+1 i 1 j min(d[i+1][j],d[i][j]) min d[i+1][j] [i+1] d i+1 i 1 j d[i][j] [i] d i j d[i+1][jx]=min(d[i][jx],d[i][j]+a,d[i+1][jx]) d[i+1][jx] [i+1] d i+1 i 1 jx min(d[i][jx],d[i][j]+a,d[i+1][jx]) min d[i][jx] [i] d i jx d[i][j]+a d[i][j] [i] d i j a d[i+1][jx] [i+1] d i+1 i 1 jx if d[-1][-1]==10**7:
  print(-1)
else:
  print(d[-1][-1]) d[-1][-1]==10**7 d[-1][-1] [-1] d -1 -1 10**7 10 7 print(-1) print -1 print(d[-1][-1]) print d[-1][-1] [-1] d -1 -1 inf=10**7 10**7 inf res+=2**(x-1) 2**(x-1) res m=map(int,input().split()) map(int,input().split()) m b=map(int,input().split()) map(int,input().split()) b n,m=map(int,input().split()) map(int,input().split()) n d=[[inf]*k for _ in range(m+1)] [[inf]*k for _ in range(m+1)] d c=list(map(int,input().split())) list(map(int,input().split())) c res=0 0 res a,b=map(int,input().split()) map(int,input().split()) a jx=j|res j|res jx k=2**n 2**n k
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n,m=map(int,input().split())
k=2**n
inf=10**7
d=[[inf]*k for _ in range(m+1)]
for i in range(m+1):
  d[i][0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    res=0
    for x in c:
        res+=2**(x-1)
    for j in range(2**n):
        jx=j|res
        d[i+1][j]=min(d[i+1][j],d[i][j])
        d[i+1][jx]=min(d[i][jx],d[i][j]+a,d[i+1][jx])
if d[-1][-1]==10**7:
  print(-1)
else:
  print(d[-1][-1])
