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

a = []

b = []

c = []



import sys

sys.setrecursionlimit(2000)



for i in range(M):

    ai, bi = list(map(int, input().split()))

    a.append(ai)

    b.append(bi)

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

    c.append(ci)



c_bin = [0] * M

for j in range(M):

    for k in range(b[j]):

        c_bin[j] |= (1 << (c[j][k] - 1))



ceil = 1 << N

memo = [None] * (ceil * (M + 1))

# print("#", '[' +' '.join(map(lambda x: '0b{:b}'.format(x), c_bin)) + ']', ceil)

def dp(pos, state):

    global M, ceil

    idx = pos * ceil + state

    # print("##", pos, '0b{:b}'.format(state), idx)

    if state == ceil - 1:

        ret = 0

    elif pos == M:

        ret = -1

    elif memo[idx] != None:

        return memo[idx]

    else:

        ret0 = dp(pos + 1, (state | c_bin[pos]))

        ret1 = dp(pos + 1, state)

        if ret0 == ret1 == -1:

            ret = -1

        elif ret1 == -1:

            ret = a[pos] + ret0

        else:

            ret = min(a[pos] + ret0, ret1)

    #

    memo[idx] = ret

    return ret



print((dp(0, 0)))

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

a = []

b = []

c = []



MY_INF = 1000000007



for _ in range(M):

    a_tmp, b_tmp = list(map(int, input().split()))

    a.append(a_tmp)

    b.append(b_tmp)

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



c_bin = []

for i in range(M):

    c_bin.append(sum([1 << (cij - 1) for cij in c[i]]))

    

memo = [None] * (1 << N)



def dp(state):

    global MY_INF

    if state == (1 << N) - 1: return 0

    if memo[state] != None: return memo[state]

    #

    rets = [MY_INF]

    for i in range(M):

        if (state | c_bin[i]) > state:

            rets.append(a[i] + dp((state | c_bin[i])))

    ret = min(rets)

    #

    memo[state] = ret

    return ret



ans = dp(0)

if ans != MY_INF:

    print(ans)

else:

    print((-1))
N, M = list(map(int, input().split()))
a = []
b = []
c = []
import sys

sys.setrecursionlimit(2000)
for i in range(M):
    ai, bi = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)
    ci = list(map(int, input().split()))
    c.append(ci)
c_bin = [0] * M
for j in range(M):
    for k in range(b[j]):
        c_bin[j] |= 1 << (c[j][k] - 1)
ceil = 1 << N
memo = [None] * (ceil * (M + 1))
# print("#", '[' +' '.join(map(lambda x: '0b{:b}'.format(x), c_bin)) + ']', ceil)
def dp(pos, state):
    global M, ceil
    idx = pos * ceil + state
    # print("##", pos, '0b{:b}'.format(state), idx)
    if state == ceil - 1:
        ret = 0
    elif pos == M:
        ret = -1
    elif memo[idx] != None:
        return memo[idx]
    else:
        ret0 = dp(pos + 1, (state | c_bin[pos]))
        ret1 = dp(pos + 1, state)
        if ret0 == ret1 == -1:
            ret = -1
        elif ret1 == -1:
            ret = a[pos] + ret0
        else:
            ret = min(a[pos] + ret0, ret1)
    #
    memo[idx] = ret
    return ret


print((dp(0, 0)))

N, M = list(map(int, input().split()))
a = []
b = []
c = []
MY_INF = 1000000007
for _ in range(M):
    a_tmp, b_tmp = list(map(int, input().split()))
    a.append(a_tmp)
    b.append(b_tmp)
    c.append(list(map(int, input().split())))
c_bin = []
for i in range(M):
    c_bin.append(sum([1 << (cij - 1) for cij in c[i]]))
memo = [None] * (1 << N)


def dp(state):
    global MY_INF
    if state == (1 << N) - 1:
        return 0
    if memo[state] != None:
        return memo[state]
    #
    rets = [MY_INF]
    for i in range(M):
        if (state | c_bin[i]) > state:
            rets.append(a[i] + dp((state | c_bin[i])))
    ret = min(rets)
    #
    memo[state] = ret
    return ret


ans = dp(0)
if ans != MY_INF:
    print(ans)
else:
    print((-1))

-import sys +MY_INF = 1000000007 +for _ in range(M): +    a_tmp, b_tmp = list(map(int, input().split())) +    a.append(a_tmp) +    b.append(b_tmp) +    c.append(list(map(int, input().split()))) +c_bin = [] +for i in range(M): +    c_bin.append(sum([1 << (cij - 1) for cij in c[i]])) +memo = [None] * (1 << N) -sys.setrecursionlimit(2000) -for i in range(M): -    ai, bi = list(map(int, input().split())) -    a.append(ai) -    b.append(bi) -    ci = list(map(int, input().split())) -    c.append(ci) -c_bin = [0] * M -for j in range(M): -    for k in range(b[j]): -        c_bin[j] |= 1 << (c[j][k] - 1) -ceil = 1 << N -memo = [None] * (ceil * (M + 1)) -# print("#", '[' +' '.join(map(lambda x: '0b{:b}'.format(x), c_bin)) + ']', ceil) -def dp(pos, state): -    global M, ceil -    idx = pos * ceil + state -    # print("##", pos, '0b{:b}'.format(state), idx) -    if state == ceil - 1: -        ret = 0 -    elif pos == M: -        ret = -1 -    elif memo[idx] != None: -        return memo[idx] -    else: -        ret0 = dp(pos + 1, (state | c_bin[pos])) -        ret1 = dp(pos + 1, state) -        if ret0 == ret1 == -1: -            ret = -1 -        elif ret1 == -1: -            ret = a[pos] + ret0 -        else: -            ret = min(a[pos] + ret0, ret1) + +def dp(state): +    global MY_INF +    if state == (1 << N) - 1: +        return 0 +    if memo[state] != None: +        return memo[state] -    memo[idx] = ret +    rets = [MY_INF] +    for i in range(M): +        if (state | c_bin[i]) > state: +            rets.append(a[i] + dp((state | c_bin[i]))) +    ret = min(rets) +    # +    memo[state] = ret -print((dp(0, 0))) +ans = dp(0) +if ans != MY_INF: +    print(ans) +else: +    print((-1))