Buggy python submission (verdict: Time Limit Exceeded):
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True  and False

def ddprint(x):
  if DBG:
    print(x)

BIG = 999999


# # # # main start

n,m = inm()
fff = 2**n - 1
dp = [BIG] * (2**n)
a = []
s = []
for i in range(m):
  aa,bb = inm()
  c = inl()
  ss = 0
  c = [x-1 for x in c]
  for cc in c:
    ss |= (1<<cc)
  a.append(aa)
  s.append(ss)

dp = [BIG] * (2**n)
dp[0] = 0

for i in range(m):
  aa = a[i]
  ss = s[i]
  for j in range(2**n):
    dp[j|ss] = min(dp[j|ss], dp[j]+aa)

v = dp[2**n-1]
print(-1 if v>=BIG else v)


Fixed submission:
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True  and False

def ddprint(x):
  if DBG:
    print(x)

BIG = 999999


# # # # main start

n,m = inm()
fff = 2**n - 1
dp = [BIG] * (2**n)
a = []
s = []
for i in range(m):
  aa,bb = inm()
  c = inl()
  ss = 0
  c = [x-1 for x in c]
  for cc in c:
    ss |= (1<<cc)
  a.append(aa)
  s.append(ss)

dp = [BIG] * (2**n)
dp[0] = 0

for i in range(m):
  aa = a[i]
  ss = s[i]
  for j in range(2**n):
    dp[j|ss] = min(dp[j|ss], dp[j]+aa)

v = dp[2**n-1]
print(-1 if v>=BIG else v)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True  and False

def ddprint(x):
  if DBG:
    print(x)

BIG = 999999

def dfs(bx, s, v):
  ddprint("dfs bx {} s {} v {}".format(bx,s,v))
  if s == fff:
    if v<dp[fff]:
      dp[fff] = v
    return dp[fff]
  if bx>=n:
    return BIG
  if v>=dp[s]:
    return dp[fff]
  bit = (1<<bx)
  if bit|s == s:
    return dfs(bx+1,s,v)
  mn = BIG
  for z in box[bx]:
    val = z[1]
    addset = z[2]
    ddprint("call newi {} newset {} newv {}".format(i+1, s|addset, v+val))
    newval = dfs(bx+1, s|addset, v+val)
    mn = min(mn, newval)
  return mn

# # # # main start

n,m = inm()
fff = 2**n - 1
dp = [BIG] * (2**n)
key = []
box = [ [] for i in range(n) ]
for i in range(m):
  a,b = inm()
  c = inl()
  s = 0
  c = [x-1 for x in c]
  for cc in c:
    s |= (1<<cc)
  v = a/len(c)
  key.append((v,a,b,c,s))
  for bx in c:
    box[bx].append((v,a,s,i))  # prio,val,set,suf

for z in box:
  z.sort()
  ddprint(z)

v = dfs(0,0,0)
print(-1 if v>=BIG else v)


Fixed submission:
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True  and False

def ddprint(x):
  if DBG:
    print(x)

BIG = 999999


# # # # main start

n,m = inm()
fff = 2**n - 1
dp = [BIG] * (2**n)
a = []
s = []
for i in range(m):
  aa,bb = inm()
  c = inl()
  ss = 0
  c = [x-1 for x in c]
  for cc in c:
    ss |= (1<<cc)
  a.append(aa)
  s.append(ss)

dp = [BIG] * (2**n)
dp[0] = 0

for i in range(m):
  aa = a[i]
  ss = s[i]
  for j in range(2**n):
    dp[j|ss] = min(dp[j|ss], dp[j]+aa)

v = dp[2**n-1]
print(-1 if v>=BIG else v)