import sys
input=sys.stdin.readline
n,m=map(int,input().split())
trs=[]
for _ in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  cnt=0
  for i in range(b):
    cnt+=2**(c[i]-1)
  trs.append((a,cnt))
dp=[10**9]*2**n
dp[0]=0
for i in range(2**n):
  for a,cnt in trs:
    dp[i|cnt]=min(dp[i]+a,dp[i|cnt])
if dp[2**n-1]!=10**9:
  print(dp[2**n-1])
else:
  print(-1) import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m trs=[] trs [] for _ in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  cnt=0
  for i in range(b):
    cnt+=2**(c[i]-1)
  trs.append((a,cnt)) _ 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 cnt=0 cnt 0 for i in range(b):
    cnt+=2**(c[i]-1)
   i range(b) range b cnt+=2**(c[i]-1) cnt 2**(c[i]-1) 2 c[i]-1 c[i] c i 1 trs.append((a,cnt)) trs.append trs append (a,cnt) a cnt dp=[10**9]*2**n dp [10**9]*2**n [10**9] 10**9 10 9 2**n 2 n dp[0]=0 dp[0] dp 0 0 for i in range(2**n):
  for a,cnt in trs:
    dp[i|cnt]=min(dp[i]+a,dp[i|cnt]) i range(2**n) range 2**n 2 n for a,cnt in trs:
    dp[i|cnt]=min(dp[i]+a,dp[i|cnt]) a cnt trs dp[i|cnt]=min(dp[i]+a,dp[i|cnt]) dp[i|cnt] dp i|cnt i cnt min(dp[i]+a,dp[i|cnt]) min dp[i]+a dp[i] dp i a dp[i|cnt] dp i|cnt i cnt if dp[2**n-1]!=10**9:
  print(dp[2**n-1])
else:
  print(-1) dp[2**n-1]!=10**9 dp[2**n-1] dp 2**n-1 2**n 2 n 1 10**9 10 9 print(dp[2**n-1]) print dp[2**n-1] dp 2**n-1 2**n 2 n 1 print(-1) print -1 input=sys.stdin.readline sys.stdin.readline input c=list(map(int,input().split())) list(map(int,input().split())) c b=map(int,input().split()) map(int,input().split()) b cnt=0 0 cnt trs=[] [] trs n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m a,b=map(int,input().split()) map(int,input().split()) a cnt+=2**(c[i]-1) 2**(c[i]-1) cnt dp=[10**9]*2**n [10**9]*2**n dp
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
trs=[]
for _ in range(m):
  a,b=map(int,input().split())
  c=list(map(int,input().split()))
  cnt=0
  for i in range(b):
    cnt+=2**(c[i]-1)
  trs.append((a,cnt))
dp=[10**9]*2**n
dp[0]=0
for i in range(2**n):
  for a,cnt in trs:
    dp[i|cnt]=min(dp[i]+a,dp[i|cnt])
if dp[2**n-1]!=10**9:
  print(dp[2**n-1])
else:
  print(-1)