from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(m):
  l2=[]
  a,b=map(int,input().split())
  l2.append(a)
  x=list(map(int,input().split()))
  ct=0
  for i in range(n):
    if i+1 in x:
      ct+=2**i
  l2.append(ct)
  l.append(l2)

dp=[[999999999999 for i in range(2**n)] for j in range(m+1)]
dp[0][0]=0
for i in range(1,m+1):
  for j in range(2**n):
    dp[i][j|l[i-1][1]]=min(dp[i-1][j]+l[i-1][0],dp[i][j|l[i-1][1]])
  for j in range(2**n):
    dp[i][j]=min(dp[i][j],dp[i-1][j])

if dp[m][2**n-1]<10**11:
  print(dp[m][2**n-1])
else:
  print(-1) from operator import itemgetter n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m l=[] l [] for i in range(m):
  l2=[]
  a,b=map(int,input().split())
  l2.append(a)
  x=list(map(int,input().split()))
  ct=0
  for i in range(n):
    if i+1 in x:
      ct+=2**i
  l2.append(ct)
  l.append(l2) i range(m) range m l2=[] l2 [] a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b l2.append(a) l2.append l2 append a x=list(map(int,input().split())) x list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ct=0 ct 0 for i in range(n):
    if i+1 in x:
      ct+=2**i
   i range(n) range n if i+1 in x:
      ct+=2**i
   i+1 in x i+1 i 1 x ct+=2**i ct 2**i 2 i l2.append(ct) l2.append l2 append ct l.append(l2) l.append l append l2 [999999999999 for i in range(2**n)] for j in range(m+1) for j in range(m+1) j range(m+1) range m+1 m 1 for j in range(m+1) [999999999999 for i in range(2**n)] dp=[[999999999999 for i in range(2**n)] for j in range(m+1)] dp [[999999999999 for i in range(2**n)] for j in range(m+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(1,m+1):
  for j in range(2**n):
    dp[i][j|l[i-1][1]]=min(dp[i-1][j]+l[i-1][0],dp[i][j|l[i-1][1]])
  for j in range(2**n):
    dp[i][j]=min(dp[i][j],dp[i-1][j]) i range(1,m+1) range 1 m+1 m 1 for j in range(2**n):
    dp[i][j|l[i-1][1]]=min(dp[i-1][j]+l[i-1][0],dp[i][j|l[i-1][1]])
   j range(2**n) range 2**n 2 n dp[i][j|l[i-1][1]]=min(dp[i-1][j]+l[i-1][0],dp[i][j|l[i-1][1]]) dp[i][j|l[i-1][1]] [i] dp i j|l[i-1][1] j l[i-1][1] [i-1] l i-1 i 1 1 min(dp[i-1][j]+l[i-1][0],dp[i][j|l[i-1][1]]) min dp[i-1][j]+l[i-1][0] dp[i-1][j] [i-1] dp i-1 i 1 j l[i-1][0] [i-1] l i-1 i 1 0 dp[i][j|l[i-1][1]] [i] dp i j|l[i-1][1] j l[i-1][1] [i-1] l i-1 i 1 1 for j in range(2**n):
    dp[i][j]=min(dp[i][j],dp[i-1][j]) j range(2**n) range 2**n 2 n dp[i][j]=min(dp[i][j],dp[i-1][j]) dp[i][j] [i] dp i j min(dp[i][j],dp[i-1][j]) min dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j if dp[m][2**n-1]<10**11:
  print(dp[m][2**n-1])
else:
  print(-1) dp[m][2**n-1]<10**11 dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 10**11 10 11 print(dp[m][2**n-1]) print dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 print(-1) print -1 a,b=map(int,input().split()) map(int,input().split()) a n,m=map(int,input().split()) map(int,input().split()) n l=[] [] l ct=0 0 ct l2=[] [] l2 dp=[[999999999999 for i in range(2**n)] for j in range(m+1)] [[999999999999 for i in range(2**n)] for j in range(m+1)] dp m=map(int,input().split()) map(int,input().split()) m b=map(int,input().split()) map(int,input().split()) b x=list(map(int,input().split())) list(map(int,input().split())) x ct+=2**i 2**i ct
from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(m):
  l2=[]
  a,b=map(int,input().split())
  l2.append(a)
  x=list(map(int,input().split()))
  ct=0
  for i in range(n):
    if i+1 in x:
      ct+=2**i
  l2.append(ct)
  l.append(l2)

dp=[[999999999999 for i in range(2**n)] for j in range(m+1)]
dp[0][0]=0
for i in range(1,m+1):
  for j in range(2**n):
    dp[i][j|l[i-1][1]]=min(dp[i-1][j]+l[i-1][0],dp[i][j|l[i-1][1]])
  for j in range(2**n):
    dp[i][j]=min(dp[i][j],dp[i-1][j])

if dp[m][2**n-1]<10**11:
  print(dp[m][2**n-1])
else:
  print(-1)
