# -*- coding: utf-8 -*-
"""
E - Get Everything
https://atcoder.jp/contests/abc142/tasks/abc142_e

"""
import sys


def solve(N, M):
    dp = [float('inf')] * 2**N
    dp[0] = 0
    for y in range(1, M+1):
        a, b = map(int, input().split())
        c = [int(i) for i in input().split()]
        t = 0
        for cc in c:
            t |= (1 << (cc-1))
        for x in range(2**N):
            if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
    return -1 if dp[-1] == float('inf') else dp[-1]


def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:]) """
E - Get Everything
https://atcoder.jp/contests/abc142/tasks/abc142_e

""" import sys sys def solve(N, M):
    dp = [float('inf')] * 2**N
    dp[0] = 0
    for y in range(1, M+1):
        a, b = map(int, input().split())
        c = [int(i) for i in input().split()]
        t = 0
        for cc in c:
            t |= (1 << (cc-1))
        for x in range(2**N):
            if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
    return -1 if dp[-1] == float('inf') else dp[-1] solve dp = [float('inf')] * 2**N dp [float('inf')] * 2**N [float('inf')] float('inf') float 'inf' 2**N 2 N dp[0] = 0 dp[0] dp 0 0 for y in range(1, M+1):
        a, b = map(int, input().split())
        c = [int(i) for i in input().split()]
        t = 0
        for cc in c:
            t |= (1 << (cc-1))
        for x in range(2**N):
            if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
     y range(1, M+1) range 1 M+1 M 1 a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i c = [int(i) for i in input().split()] c [int(i) for i in input().split()] t = 0 t 0 for cc in c:
            t |= (1 << (cc-1))
         cc c t |= (1 << (cc-1)) t 1 << (cc-1) 1 cc-1 cc 1 for x in range(2**N):
            if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
     x range(2**N) range 2**N 2 N if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
     dp[x|t] > dp[x] + a dp[x|t] dp x|t x t dp[x] + a dp[x] dp x a dp[x|t] = dp[x] + a dp[x|t] dp x|t x t dp[x] + a dp[x] dp x a return -1 if dp[-1] == float('inf') else dp[-1] -1 if dp[-1] == float('inf') else dp[-1] dp[-1] == float('inf') dp[-1] dp -1 float('inf') float 'inf' -1 dp[-1] dp -1 N N M M def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M ans = solve(N, M) ans solve(N, M) solve N M print(ans) print ans args args if __name__ == '__main__':
    main(sys.argv[1:]) __name__ == '__main__' __name__ '__main__' main(sys.argv[1:]) main sys.argv[1:] sys.argv sys argv 1: 1 def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans) def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans) main def solve(N, M):
    dp = [float('inf')] * 2**N
    dp[0] = 0
    for y in range(1, M+1):
        a, b = map(int, input().split())
        c = [int(i) for i in input().split()]
        t = 0
        for cc in c:
            t |= (1 << (cc-1))
        for x in range(2**N):
            if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
    return -1 if dp[-1] == float('inf') else dp[-1] def solve(N, M):
    dp = [float('inf')] * 2**N
    dp[0] = 0
    for y in range(1, M+1):
        a, b = map(int, input().split())
        c = [int(i) for i in input().split()]
        t = 0
        for cc in c:
            t |= (1 << (cc-1))
        for x in range(2**N):
            if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
    return -1 if dp[-1] == float('inf') else dp[-1] solve
# -*- coding: utf-8 -*-
"""
E - Get Everything
https://atcoder.jp/contests/abc142/tasks/abc142_e

"""
import sys


def solve(N, M):
    dp = [float('inf')] * 2**N
    dp[0] = 0
    for y in range(1, M+1):
        a, b = map(int, input().split())
        c = [int(i) for i in input().split()]
        t = 0
        for cc in c:
            t |= (1 << (cc-1))
        for x in range(2**N):
            if dp[x|t] > dp[x] + a:
                dp[x|t] = dp[x] + a
    return -1 if dp[-1] == float('inf') else dp[-1]


def main(args):
    N, M = map(int, input().split())
    ans = solve(N, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
