import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline

INF = 10**9 + 7

N, M = map(int, readline().split())
key = [()] * M

for i in range(M):
    a, b = map(int, readline().split())
    c = map(int, readline().split())
    num = 0
    for j in c:
        num += 1 << (j - 1)
    key[i] = (num, a)


def solve():

    dp = [INF for _ in range(2**N)]
    dp[0] = 0

    for i in range(M):
        num, a = key[i]
        for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

    if dp[2**N - 1] == INF:
        ans = -1
    else:
        ans = dp[2**N - 1]

    print(ans)


if __name__ == '__main__':
    solve() import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines s_readline = sys.stdin.readline s_readline sys.stdin.readline sys.stdin sys stdin readline INF = 10**9 + 7 INF 10**9 + 7 10**9 10 9 7 N, M = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split M key = [()] * M key [()] * M [()] () M for i in range(M):
    a, b = map(int, readline().split())
    c = map(int, readline().split())
    num = 0
    for j in c:
        num += 1 << (j - 1)
    key[i] = (num, a) i range(M) range M a, b = map(int, readline().split()) a map(int, readline().split()) map int readline().split() ().split () readline split b c = map(int, readline().split()) c map(int, readline().split()) map int readline().split() ().split () readline split num = 0 num 0 for j in c:
        num += 1 << (j - 1)
     j c num += 1 << (j - 1) num 1 << (j - 1) 1 j - 1 j 1 key[i] = (num, a) key[i] key i (num, a) num a def solve():

    dp = [INF for _ in range(2**N)]
    dp[0] = 0

    for i in range(M):
        num, a = key[i]
        for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

    if dp[2**N - 1] == INF:
        ans = -1
    else:
        ans = dp[2**N - 1]

    print(ans) solve INF for _ in range(2**N) for _ in range(2**N) _ range(2**N) range 2**N 2 N for _ in range(2**N) INF dp = [INF for _ in range(2**N)] dp [INF for _ in range(2**N)] dp[0] = 0 dp[0] dp 0 0 for i in range(M):
        num, a = key[i]
        for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

     i range(M) range M num, a = key[i] num key[i] key i a for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

     j range(2**N) range 2**N 2 N next_num = j | num next_num j | num j num dp[next_num] = min(dp[next_num], dp[j] + a) dp[next_num] dp next_num min(dp[next_num], dp[j] + a) min dp[next_num] dp next_num dp[j] + a dp[j] dp j a if dp[2**N - 1] == INF:
        ans = -1
    else:
        ans = dp[2**N - 1]

     dp[2**N - 1] == INF dp[2**N - 1] dp 2**N - 1 2**N 2 N 1 INF ans = -1 ans -1 ans = dp[2**N - 1] ans dp[2**N - 1] dp 2**N - 1 2**N 2 N 1 print(ans) print ans if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve INF = 10**9 + 7 10**9 + 7 INF M = map(int, readline().split()) map(int, readline().split()) M key = [()] * M [()] * M key readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines read = sys.stdin.buffer.read sys.stdin.buffer.read read N, M = map(int, readline().split()) map(int, readline().split()) N s_readline = sys.stdin.readline sys.stdin.readline s_readline b = map(int, readline().split()) map(int, readline().split()) b readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline c = map(int, readline().split()) map(int, readline().split()) c num = 0 0 num num += 1 << (j - 1) 1 << (j - 1) num a, b = map(int, readline().split()) map(int, readline().split()) a def solve():

    dp = [INF for _ in range(2**N)]
    dp[0] = 0

    for i in range(M):
        num, a = key[i]
        for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

    if dp[2**N - 1] == INF:
        ans = -1
    else:
        ans = dp[2**N - 1]

    print(ans) def solve():

    dp = [INF for _ in range(2**N)]
    dp[0] = 0

    for i in range(M):
        num, a = key[i]
        for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

    if dp[2**N - 1] == INF:
        ans = -1
    else:
        ans = dp[2**N - 1]

    print(ans) solve
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline

INF = 10**9 + 7

N, M = map(int, readline().split())
key = [()] * M

for i in range(M):
    a, b = map(int, readline().split())
    c = map(int, readline().split())
    num = 0
    for j in c:
        num += 1 << (j - 1)
    key[i] = (num, a)


def solve():

    dp = [INF for _ in range(2**N)]
    dp[0] = 0

    for i in range(M):
        num, a = key[i]
        for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

    if dp[2**N - 1] == INF:
        ans = -1
    else:
        ans = dp[2**N - 1]

    print(ans)


if __name__ == '__main__':
    solve()
