n,m = list(map(int,input().split()))

tr = [ 10 ** 18 for _ in range(2**n) ]

tr[0] = 0

key = []

for _ in range(m):

  cost,b = list(map(int,input().split()))

  raw = list(map(int,input().split()))

  get = 0

  for i in range(b):

    get += 2 ** (raw[i]-1)

  key.append([get,cost])

#print(key)

key.sort()

#print(key)

for j in range(2**n):

  for k in range(m):

    get,cost = key[k]

    tr[get | j] = min(tr[get | j],cost+tr[j])

    #print(tr,get,j,get | j)

    #print(get^j,get,j)

  #print(tr)

if tr[2**n-1] == 10 ** 18:

  print((-1))

else:

  print((tr[2**n-1]))
n,m = list(map(int,input().split()))

inf = 10 ** 18

cost = [inf for _ in range(2**n)]

cost[0] = 0

for _ in range(m):

  a,b = list(map(int,input().split()))

  c = list(map(int,input().split()))

  key = 0

  for i in range(b):

    key += 2 ** (c[i]-1)

  #print(key)

  for t in range(2**n):

    cost[t|key] = min(cost[t|key],cost[t]+a)

#print(cost)

ans = cost[-1]

if ans < inf:

  print(ans)

else:

  print((-1))
n, m = list(map(int, input().split()))
tr = [10**18 for _ in range(2**n)]
tr[0] = 0
key = []
for _ in range(m):
    cost, b = list(map(int, input().split()))
    raw = list(map(int, input().split()))
    get = 0
    for i in range(b):
        get += 2 ** (raw[i] - 1)
    key.append([get, cost])
# print(key)
key.sort()
# print(key)
for j in range(2**n):
    for k in range(m):
        get, cost = key[k]
        tr[get | j] = min(tr[get | j], cost + tr[j])
        # print(tr,get,j,get | j)
        # print(get^j,get,j)
    # print(tr)
if tr[2**n - 1] == 10**18:
    print((-1))
else:
    print((tr[2**n - 1]))

n, m = list(map(int, input().split()))
inf = 10**18
cost = [inf for _ in range(2**n)]
cost[0] = 0
for _ in range(m):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    key = 0
    for i in range(b):
        key += 2 ** (c[i] - 1)
    # print(key)
    for t in range(2**n):
        cost[t | key] = min(cost[t | key], cost[t] + a)
# print(cost)
ans = cost[-1]
if ans < inf:
    print(ans)
else:
    print((-1))

-tr = [10**18 for _ in range(2**n)] -tr[0] = 0 -key = [] +inf = 10**18 +cost = [inf for _ in range(2**n)] +cost[0] = 0 -    cost, b = list(map(int, input().split())) -    raw = list(map(int, input().split())) -    get = 0 +    a, b = list(map(int, input().split())) +    c = list(map(int, input().split())) +    key = 0 -        get += 2 ** (raw[i] - 1) -    key.append([get, cost]) -# print(key) -key.sort() -# print(key) -for j in range(2**n): -    for k in range(m): -        get, cost = key[k] -        tr[get | j] = min(tr[get | j], cost + tr[j]) -        # print(tr,get,j,get | j) -        # print(get^j,get,j) -    # print(tr) -if tr[2**n - 1] == 10**18: +        key += 2 ** (c[i] - 1) +    # print(key) +    for t in range(2**n): +        cost[t | key] = min(cost[t | key], cost[t] + a) +# print(cost) +ans = cost[-1] +if ans < inf: +    print(ans) +else: -else: -    print((tr[2**n - 1]))