

def compute(subset):
	r = 0
	for i in range(len(subset)):
		r +=  (1 << (subset[i]-1))
	return r	

n,m = map(int, raw_input().split(' '))
keys= []
for _ in range(m):
	cost, nk = map(int, raw_input().split(' '))
	keys.append((cost, compute( map(int, raw_input().split(' ')) )))

h = {0:0}
for cost,mask in keys:
	for uu in range(2 ** n - 1,-1,-1):
		cm = uu & mask
		cm = uu ^ (cm) 
		h[uu] = min(h[uu] if uu in h else +float('inf'), (h[cm] if cm in h else +float('inf')) + cost )
print h[2 ** n -1] if (2 ** n -1) in h and h[(2 ** n) -1] < float('inf') else -1 def compute(subset):
	r = 0
	for i in range(len(subset)):
		r +=  (1 << (subset[i]-1))
	return r	 compute r = 0 r 0 for i in range(len(subset)):
		r +=  (1 << (subset[i]-1))
	 i range(len(subset)) range len(subset) len subset r +=  (1 << (subset[i]-1)) r 1 << (subset[i]-1) 1 subset[i]-1 subset[i] subset i 1 return r r subset subset n,m = map(int, raw_input().split(' ')) n map(int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' m keys= [] keys [] for _ in range(m):
	cost, nk = map(int, raw_input().split(' '))
	keys.append((cost, compute( map(int, raw_input().split(' ')) ))) _ range(m) range m cost, nk = map(int, raw_input().split(' ')) cost map(int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' nk keys.append((cost, compute( map(int, raw_input().split(' ')) ))) keys.append keys append (cost, compute( map(int, raw_input().split(' ')) )) cost compute( map(int, raw_input().split(' ')) ) compute map(int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' h = {0:0} h {0:0} 0 0 0 for cost,mask in keys:
	for uu in range(2 ** n - 1,-1,-1):
		cm = uu & mask
		cm = uu ^ (cm) 
		h[uu] = min(h[uu] if uu in h else +float('inf'), (h[cm] if cm in h else +float('inf')) + cost ) cost mask keys for uu in range(2 ** n - 1,-1,-1):
		cm = uu & mask
		cm = uu ^ (cm) 
		h[uu] = min(h[uu] if uu in h else +float('inf'), (h[cm] if cm in h else +float('inf')) + cost ) uu range(2 ** n - 1,-1,-1) range 2 ** n - 1 2 ** n 2 n 1 -1 -1 cm = uu & mask cm uu & mask uu mask cm = uu ^ (cm) cm uu ^ (cm) uu cm h[uu] = min(h[uu] if uu in h else +float('inf'), (h[cm] if cm in h else +float('inf')) + cost ) h[uu] h uu min(h[uu] if uu in h else +float('inf'), (h[cm] if cm in h else +float('inf')) + cost ) min h[uu] if uu in h else +float('inf') uu in h uu h h[uu] h uu +float('inf') float('inf') float 'inf' (h[cm] if cm in h else +float('inf')) + cost h[cm] if cm in h else +float('inf') cm in h cm h h[cm] h cm +float('inf') float('inf') float 'inf' cost print h[2 ** n -1] if (2 ** n -1) in h and h[(2 ** n) -1] < float('inf') else -1 (2 ** n -1) in h and h[(2 ** n) -1] < float('inf') (2 ** n -1) in h 2 ** n -1 2 ** n 2 n 1 h h[(2 ** n) -1] < float('inf') h[(2 ** n) -1] h (2 ** n) -1 2 ** n 2 n 1 float('inf') float 'inf' h[2 ** n -1] h 2 ** n -1 2 ** n 2 n 1 -1 cm = uu ^ (cm) uu ^ (cm) cm def compute(subset):
	r = 0
	for i in range(len(subset)):
		r +=  (1 << (subset[i]-1))
	return r	 def compute(subset):
	r = 0
	for i in range(len(subset)):
		r +=  (1 << (subset[i]-1))
	return r	 compute cost, nk = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) cost n,m = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) n nk = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) nk h = {0:0} {0:0} h cm = uu & mask uu & mask cm keys= [] [] keys m = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) m


def compute(subset):
	r = 0
	for i in range(len(subset)):
		r +=  (1 << (subset[i]-1))
	return r	

n,m = map(int, raw_input().split(' '))
keys= []
for _ in range(m):
	cost, nk = map(int, raw_input().split(' '))
	keys.append((cost, compute( map(int, raw_input().split(' ')) )))

h = {0:0}
for cost,mask in keys:
	for uu in range(2 ** n - 1,-1,-1):
		cm = uu & mask
		cm = uu ^ (cm) 
		h[uu] = min(h[uu] if uu in h else +float('inf'), (h[cm] if cm in h else +float('inf')) + cost )
print h[2 ** n -1] if (2 ** n -1) in h and h[(2 ** n) -1] < float('inf') else -1
