import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())

    dp = [10 ** 9] * pow(2,N)
    dp[0] = 0

    for j in range(M):
        a, b = map(int, input().split())
        c = sum([pow(2, int(i) - 1) for i in input().split()])
        for i in range(pow(2,N)):
            dp[i | c] = min(dp[i | c], dp[i] + a)

    print(dp[-1] if dp[-1] !=10**9 else -1)


if __name__ == "__main__":
    main() import sys sys def input():
    return sys.stdin.readline().rstrip() input return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    N, M = map(int, input().split())

    dp = [10 ** 9] * pow(2,N)
    dp[0] = 0

    for j in range(M):
        a, b = map(int, input().split())
        c = sum([pow(2, int(i) - 1) for i in input().split()])
        for i in range(pow(2,N)):
            dp[i | c] = min(dp[i | c], dp[i] + a)

    print(dp[-1] if dp[-1] !=10**9 else -1) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M dp = [10 ** 9] * pow(2,N) dp [10 ** 9] * pow(2,N) [10 ** 9] 10 ** 9 10 9 pow(2,N) pow 2 N dp[0] = 0 dp[0] dp 0 0 for j in range(M):
        a, b = map(int, input().split())
        c = sum([pow(2, int(i) - 1) for i in input().split()])
        for i in range(pow(2,N)):
            dp[i | c] = min(dp[i | c], dp[i] + a)

     j range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b pow(2, int(i) - 1) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() pow(2, int(i) - 1) pow 2 int(i) - 1 int(i) int i 1 c = sum([pow(2, int(i) - 1) for i in input().split()]) c sum([pow(2, int(i) - 1) for i in input().split()]) sum [pow(2, int(i) - 1) for i in input().split()] for i in range(pow(2,N)):
            dp[i | c] = min(dp[i | c], dp[i] + a)

     i range(pow(2,N)) range pow(2,N) pow 2 N dp[i | c] = min(dp[i | c], dp[i] + a) dp[i | c] dp i | c i c min(dp[i | c], dp[i] + a) min dp[i | c] dp i | c i c dp[i] + a dp[i] dp i a print(dp[-1] if dp[-1] !=10**9 else -1) print dp[-1] if dp[-1] !=10**9 else -1 dp[-1] !=10**9 dp[-1] dp -1 10**9 10 9 dp[-1] dp -1 -1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, M = map(int, input().split())

    dp = [10 ** 9] * pow(2,N)
    dp[0] = 0

    for j in range(M):
        a, b = map(int, input().split())
        c = sum([pow(2, int(i) - 1) for i in input().split()])
        for i in range(pow(2,N)):
            dp[i | c] = min(dp[i | c], dp[i] + a)

    print(dp[-1] if dp[-1] !=10**9 else -1) def main():
    N, M = map(int, input().split())

    dp = [10 ** 9] * pow(2,N)
    dp[0] = 0

    for j in range(M):
        a, b = map(int, input().split())
        c = sum([pow(2, int(i) - 1) for i in input().split()])
        for i in range(pow(2,N)):
            dp[i | c] = min(dp[i | c], dp[i] + a)

    print(dp[-1] if dp[-1] !=10**9 else -1) main def input():
    return sys.stdin.readline().rstrip() def input():
    return sys.stdin.readline().rstrip() input
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())

    dp = [10 ** 9] * pow(2,N)
    dp[0] = 0

    for j in range(M):
        a, b = map(int, input().split())
        c = sum([pow(2, int(i) - 1) for i in input().split()])
        for i in range(pow(2,N)):
            dp[i | c] = min(dp[i | c], dp[i] + a)

    print(dp[-1] if dp[-1] !=10**9 else -1)


if __name__ == "__main__":
    main()
