import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))

    a = [0] * m
    c = [0] * m

    for i in range(m):
        a[i], _ = list(map(int, readline().split()))
        t = list(map(int, readline().split()))
        for x in t:
            c[i] += (1 << (x - 1))

    dp = [[INF] * (1 << n) for _ in range(m)]
    dp[0][c[0]] = a[0]

    for i in range(m):
        dp[i][0] = 0

    for i in range(1, m):
        key = c[i]
        price = a[i]
        for j in range(1 << n):
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

    ans = dp[-1][-1]
    if ans == INF:
        ans = -1
    print(ans)


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 def main():
    n, m = list(map(int, readline().split()))

    a = [0] * m
    c = [0] * m

    for i in range(m):
        a[i], _ = list(map(int, readline().split()))
        t = list(map(int, readline().split()))
        for x in t:
            c[i] += (1 << (x - 1))

    dp = [[INF] * (1 << n) for _ in range(m)]
    dp[0][c[0]] = a[0]

    for i in range(m):
        dp[i][0] = 0

    for i in range(1, m):
        key = c[i]
        price = a[i]
        for j in range(1 << n):
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

    ans = dp[-1][-1]
    if ans == INF:
        ans = -1
    print(ans) main n, m = list(map(int, readline().split())) n list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split m a = [0] * m a [0] * m [0] 0 m c = [0] * m c [0] * m [0] 0 m for i in range(m):
        a[i], _ = list(map(int, readline().split()))
        t = list(map(int, readline().split()))
        for x in t:
            c[i] += (1 << (x - 1))

     i range(m) range m a[i], _ = list(map(int, readline().split())) a[i] a i list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split _ t = list(map(int, readline().split())) t list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split for x in t:
            c[i] += (1 << (x - 1))

     x t c[i] += (1 << (x - 1)) c[i] c i 1 << (x - 1) 1 x - 1 x 1 [INF] * (1 << n) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [INF] * (1 << n) [INF] INF 1 << n 1 n dp = [[INF] * (1 << n) for _ in range(m)] dp [[INF] * (1 << n) for _ in range(m)] dp[0][c[0]] = a[0] dp[0][c[0]] [0] dp 0 c[0] c 0 a[0] a 0 for i in range(m):
        dp[i][0] = 0

     i range(m) range m dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for i in range(1, m):
        key = c[i]
        price = a[i]
        for j in range(1 << n):
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

     i range(1, m) range 1 m key = c[i] key c[i] c i price = a[i] price a[i] a i for j in range(1 << n):
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

     j range(1 << n) range 1 << n 1 n dp[i][j] = min(dp[i][j], dp[i - 1][j]) dp[i][j] [i] dp i j min(dp[i][j], dp[i - 1][j]) min dp[i][j] [i] dp i j dp[i - 1][j] [i - 1] dp i - 1 i 1 j if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

     dp[i - 1][j] != INF dp[i - 1][j] [i - 1] dp i - 1 i 1 j INF dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price) dp[i][j | key] [i] dp i j | key j key min(dp[i][j | key], dp[i - 1][j] + price) min dp[i][j | key] [i] dp i j | key j key dp[i - 1][j] + price dp[i - 1][j] [i - 1] dp i - 1 i 1 j price ans = dp[-1][-1] ans dp[-1][-1] [-1] dp -1 -1 if ans == INF:
        ans = -1
     ans == INF ans INF ans = -1 ans -1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.readline sys.stdin.readline readline MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def main():
    n, m = list(map(int, readline().split()))

    a = [0] * m
    c = [0] * m

    for i in range(m):
        a[i], _ = list(map(int, readline().split()))
        t = list(map(int, readline().split()))
        for x in t:
            c[i] += (1 << (x - 1))

    dp = [[INF] * (1 << n) for _ in range(m)]
    dp[0][c[0]] = a[0]

    for i in range(m):
        dp[i][0] = 0

    for i in range(1, m):
        key = c[i]
        price = a[i]
        for j in range(1 << n):
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

    ans = dp[-1][-1]
    if ans == INF:
        ans = -1
    print(ans) def main():
    n, m = list(map(int, readline().split()))

    a = [0] * m
    c = [0] * m

    for i in range(m):
        a[i], _ = list(map(int, readline().split()))
        t = list(map(int, readline().split()))
        for x in t:
            c[i] += (1 << (x - 1))

    dp = [[INF] * (1 << n) for _ in range(m)]
    dp[0][c[0]] = a[0]

    for i in range(m):
        dp[i][0] = 0

    for i in range(1, m):
        key = c[i]
        price = a[i]
        for j in range(1 << n):
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

    ans = dp[-1][-1]
    if ans == INF:
        ans = -1
    print(ans) main INF = float('INF') float('INF') INF
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))

    a = [0] * m
    c = [0] * m

    for i in range(m):
        a[i], _ = list(map(int, readline().split()))
        t = list(map(int, readline().split()))
        for x in t:
            c[i] += (1 << (x - 1))

    dp = [[INF] * (1 << n) for _ in range(m)]
    dp[0][c[0]] = a[0]

    for i in range(m):
        dp[i][0] = 0

    for i in range(1, m):
        key = c[i]
        price = a[i]
        for j in range(1 << n):
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
            if dp[i - 1][j] != INF:
                dp[i][j | key] = min(dp[i][j | key], dp[i - 1][j] + price)

    ans = dp[-1][-1]
    if ans == INF:
        ans = -1
    print(ans)


if __name__ == '__main__':
    main()
