import sys

input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())
    keys = [None] * M
    for i in range(M):
        a, b = map(int, input().split())
        s = 0
        for c in map(int, input().split()):
            c -= 1
            s |= 1 << c
        keys[i] = (s, a)

    dp = [INF] * (2 ** N)
    dp[0] = 0
    for s in range(2 ** N):
        for key, a in keys:
            t = s | key
            dp[t] = min(dp[t], dp[s] + a)

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


if __name__ == "__main__":
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline INF = float("inf") INF float("inf") float "inf" def main():
    N, M = map(int, input().split())
    keys = [None] * M
    for i in range(M):
        a, b = map(int, input().split())
        s = 0
        for c in map(int, input().split()):
            c -= 1
            s |= 1 << c
        keys[i] = (s, a)

    dp = [INF] * (2 ** N)
    dp[0] = 0
    for s in range(2 ** N):
        for key, a in keys:
            t = s | key
            dp[t] = min(dp[t], dp[s] + a)

    ans = dp[-1] if dp[-1] != INF else -1
    print(ans) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M keys = [None] * M keys [None] * M [None] None M for i in range(M):
        a, b = map(int, input().split())
        s = 0
        for c in map(int, input().split()):
            c -= 1
            s |= 1 << c
        keys[i] = (s, a)

     i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b s = 0 s 0 for c in map(int, input().split()):
            c -= 1
            s |= 1 << c
         c map(int, input().split()) map int input().split() ().split () input split c -= 1 c 1 s |= 1 << c s 1 << c 1 c keys[i] = (s, a) keys[i] keys i (s, a) s a dp = [INF] * (2 ** N) dp [INF] * (2 ** N) [INF] INF 2 ** N 2 N dp[0] = 0 dp[0] dp 0 0 for s in range(2 ** N):
        for key, a in keys:
            t = s | key
            dp[t] = min(dp[t], dp[s] + a)

     s range(2 ** N) range 2 ** N 2 N for key, a in keys:
            t = s | key
            dp[t] = min(dp[t], dp[s] + a)

     key a keys t = s | key t s | key s key dp[t] = min(dp[t], dp[s] + a) dp[t] dp t min(dp[t], dp[s] + a) min dp[t] dp t dp[s] + a dp[s] dp s a ans = dp[-1] if dp[-1] != INF else -1 ans dp[-1] if dp[-1] != INF else -1 dp[-1] != INF dp[-1] dp -1 INF dp[-1] dp -1 -1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, M = map(int, input().split())
    keys = [None] * M
    for i in range(M):
        a, b = map(int, input().split())
        s = 0
        for c in map(int, input().split()):
            c -= 1
            s |= 1 << c
        keys[i] = (s, a)

    dp = [INF] * (2 ** N)
    dp[0] = 0
    for s in range(2 ** N):
        for key, a in keys:
            t = s | key
            dp[t] = min(dp[t], dp[s] + a)

    ans = dp[-1] if dp[-1] != INF else -1
    print(ans) def main():
    N, M = map(int, input().split())
    keys = [None] * M
    for i in range(M):
        a, b = map(int, input().split())
        s = 0
        for c in map(int, input().split()):
            c -= 1
            s |= 1 << c
        keys[i] = (s, a)

    dp = [INF] * (2 ** N)
    dp[0] = 0
    for s in range(2 ** N):
        for key, a in keys:
            t = s | key
            dp[t] = min(dp[t], dp[s] + a)

    ans = dp[-1] if dp[-1] != INF else -1
    print(ans) main input = sys.stdin.readline sys.stdin.readline input INF = float("inf") float("inf") INF
import sys

input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())
    keys = [None] * M
    for i in range(M):
        a, b = map(int, input().split())
        s = 0
        for c in map(int, input().split()):
            c -= 1
            s |= 1 << c
        keys[i] = (s, a)

    dp = [INF] * (2 ** N)
    dp[0] = 0
    for s in range(2 ** N):
        for key, a in keys:
            t = s | key
            dp[t] = min(dp[t], dp[s] + a)

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


if __name__ == "__main__":
    main()
