N, M = list(map(int, input().split()))

newcount = [float('inf') for _ in range(2**N)]

newcount[0] = 0



for k in range(M):

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

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

  bit = 0

  for k in range(b):

    bit += 2**(c[k]-1)

  count = tuple(newcount)

  for k in range(2**N):

    now = bit|k

    newcount[now] = min(newcount[now], a+count[k])

count = newcount

if count[-1] < 10**6:

  print((count[-1]))

else:

  print((-1))



N, M = list(map(int, input().split()))

newcount = [100000000 for _ in range(2**N)]

newcount[0] = 0

bi = [1,2,4,8,16,32,64,128,256,512,1024,2048]

for k in range(M):

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

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

  bit = 0

  for k in range(b):

    bit += bi[c[k]-1]

  count = tuple(newcount)

  for k in range(2**N):

    now = bit|k

    newcount[now] = min(newcount[now], a+count[k])

if newcount[-1] < 10**7:

  print((newcount[-1]))

else:

  print((-1))
N, M = list(map(int, input().split()))
newcount = [float("inf") for _ in range(2**N)]
newcount[0] = 0
for k in range(M):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    bit = 0
    for k in range(b):
        bit += 2 ** (c[k] - 1)
    count = tuple(newcount)
    for k in range(2**N):
        now = bit | k
        newcount[now] = min(newcount[now], a + count[k])
count = newcount
if count[-1] < 10**6:
    print((count[-1]))
else:
    print((-1))

N, M = list(map(int, input().split()))
newcount = [100000000 for _ in range(2**N)]
newcount[0] = 0
bi = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
for k in range(M):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    bit = 0
    for k in range(b):
        bit += bi[c[k] - 1]
    count = tuple(newcount)
    for k in range(2**N):
        now = bit | k
        newcount[now] = min(newcount[now], a + count[k])
if newcount[-1] < 10**7:
    print((newcount[-1]))
else:
    print((-1))

-newcount = [float("inf") for _ in range(2**N)] +newcount = [100000000 for _ in range(2**N)] +bi = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048] -        bit += 2 ** (c[k] - 1) +        bit += bi[c[k] - 1] -count = newcount -if count[-1] < 10**6: -    print((count[-1])) +if newcount[-1] < 10**7: +    print((newcount[-1]))