def main():
    inf = 10 ** 8 + 1
    N, M = map(int, input().split())

    dp = [inf] * (1 << N)
    dp[0] = 0

    for _ in range(M):
        price, _ = map(int, input().split())
        c = (int(x) - 1 for x in input().split())
        k = sum(1 << x for x in c)
        for bit in reversed(range(1 << N)):
            nbit = bit | k
            dp[nbit] = min(dp[nbit], dp[bit] + price)

    ans = dp[(1 << N) - 1]
    if ans == inf:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split()) def main():
    inf = 10 ** 8 + 1
    N, M = map(int, input().split())

    dp = [inf] * (1 << N)
    dp[0] = 0

    for _ in range(M):
        price, _ = map(int, input().split())
        c = (int(x) - 1 for x in input().split())
        k = sum(1 << x for x in c)
        for bit in reversed(range(1 << N)):
            nbit = bit | k
            dp[nbit] = min(dp[nbit], dp[bit] + price)

    ans = dp[(1 << N) - 1]
    if ans == inf:
        print(-1)
    else:
        print(ans) main inf = 10 ** 8 + 1 inf 10 ** 8 + 1 10 ** 8 10 8 1 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M dp = [inf] * (1 << N) dp [inf] * (1 << N) [inf] inf 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for _ in range(M):
        price, _ = map(int, input().split())
        c = (int(x) - 1 for x in input().split())
        k = sum(1 << x for x in c)
        for bit in reversed(range(1 << N)):
            nbit = bit | k
            dp[nbit] = min(dp[nbit], dp[bit] + price)

     _ range(M) range M price, _ = map(int, input().split()) price map(int, input().split()) map int input().split() ().split () input split _ int(x) - 1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) - 1 int(x) int x 1 c = (int(x) - 1 for x in input().split()) c (int(x) - 1 for x in input().split()) k = sum(1 << x for x in c) k sum(1 << x for x in c) sum 1 << x 1 x for bit in reversed(range(1 << N)):
            nbit = bit | k
            dp[nbit] = min(dp[nbit], dp[bit] + price)

     bit reversed(range(1 << N)) reversed range(1 << N) range 1 << N 1 N nbit = bit | k nbit bit | k bit k dp[nbit] = min(dp[nbit], dp[bit] + price) dp[nbit] dp nbit min(dp[nbit], dp[bit] + price) min dp[nbit] dp nbit dp[bit] + price dp[bit] dp bit price ans = dp[(1 << N) - 1] ans dp[(1 << N) - 1] dp (1 << N) - 1 1 << N 1 N 1 if ans == inf:
        print(-1)
    else:
        print(ans) ans == inf ans inf print(-1) print -1 print(ans) print ans if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split()) __name__ == '__main__' __name__ '__main__' main() main def main():
    inf = 10 ** 8 + 1
    N, M = map(int, input().split())

    dp = [inf] * (1 << N)
    dp[0] = 0

    for _ in range(M):
        price, _ = map(int, input().split())
        c = (int(x) - 1 for x in input().split())
        k = sum(1 << x for x in c)
        for bit in reversed(range(1 << N)):
            nbit = bit | k
            dp[nbit] = min(dp[nbit], dp[bit] + price)

    ans = dp[(1 << N) - 1]
    if ans == inf:
        print(-1)
    else:
        print(ans) def main():
    inf = 10 ** 8 + 1
    N, M = map(int, input().split())

    dp = [inf] * (1 << N)
    dp[0] = 0

    for _ in range(M):
        price, _ = map(int, input().split())
        c = (int(x) - 1 for x in input().split())
        k = sum(1 << x for x in c)
        for bit in reversed(range(1 << N)):
            nbit = bit | k
            dp[nbit] = min(dp[nbit], dp[bit] + price)

    ans = dp[(1 << N) - 1]
    if ans == inf:
        print(-1)
    else:
        print(ans) main
def main():
    inf = 10 ** 8 + 1
    N, M = map(int, input().split())

    dp = [inf] * (1 << N)
    dp[0] = 0

    for _ in range(M):
        price, _ = map(int, input().split())
        c = (int(x) - 1 for x in input().split())
        k = sum(1 << x for x in c)
        for bit in reversed(range(1 << N)):
            nbit = bit | k
            dp[nbit] = min(dp[nbit], dp[bit] + price)

    ans = dp[(1 << N) - 1]
    if ans == inf:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
