import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7
sys.setrecursionlimit(20000000)
INF = float("inf")


def main():
    N, M = map(int, input().split())
    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = list(map(lambda x: int(x) - 1, input().split()))
        state = 0
        for c in C:
            state += 2 ** c
        key.append((a, state))
    dp = [INF for _ in range(2 ** N)]
    dp[0] = 0
    for i in range(2 ** N - 1):
        for k in range(M):
            state = key[k][1]
            tmp = dp[i] + key[k][0]
            if dp[i | state] > tmp:
                dp[i | state] = tmp
    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1])


if __name__ == "__main__":
    main() import sys sys from collections import defaultdict def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 sys.setrecursionlimit(20000000) sys.setrecursionlimit sys setrecursionlimit 20000000 INF = float("inf") INF float("inf") float "inf" def main():
    N, M = map(int, input().split())
    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = list(map(lambda x: int(x) - 1, input().split()))
        state = 0
        for c in C:
            state += 2 ** c
        key.append((a, state))
    dp = [INF for _ in range(2 ** N)]
    dp[0] = 0
    for i in range(2 ** N - 1):
        for k in range(M):
            state = key[k][1]
            tmp = dp[i] + key[k][0]
            if dp[i | state] > tmp:
                dp[i | state] = tmp
    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1]) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M key = [] key [] for _ in range(M):
        a, b = map(int, input().split())
        C = list(map(lambda x: int(x) - 1, input().split()))
        state = 0
        for c in C:
            state += 2 ** c
        key.append((a, state))
     _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b C = list(map(lambda x: int(x) - 1, input().split())) C list(map(lambda x: int(x) - 1, input().split())) list map(lambda x: int(x) - 1, input().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x input().split() ().split () input split state = 0 state 0 for c in C:
            state += 2 ** c
         c C state += 2 ** c state 2 ** c 2 c key.append((a, state)) key.append key append (a, state) a state INF for _ in range(2 ** N) for _ in range(2 ** N) _ range(2 ** N) range 2 ** N 2 N for _ in range(2 ** N) INF dp = [INF for _ in range(2 ** N)] dp [INF for _ in range(2 ** N)] dp[0] = 0 dp[0] dp 0 0 for i in range(2 ** N - 1):
        for k in range(M):
            state = key[k][1]
            tmp = dp[i] + key[k][0]
            if dp[i | state] > tmp:
                dp[i | state] = tmp
     i range(2 ** N - 1) range 2 ** N - 1 2 ** N 2 N 1 for k in range(M):
            state = key[k][1]
            tmp = dp[i] + key[k][0]
            if dp[i | state] > tmp:
                dp[i | state] = tmp
     k range(M) range M state = key[k][1] state key[k][1] [k] key k 1 tmp = dp[i] + key[k][0] tmp dp[i] + key[k][0] dp[i] dp i key[k][0] [k] key k 0 if dp[i | state] > tmp:
                dp[i | state] = tmp
     dp[i | state] > tmp dp[i | state] dp i | state i state tmp dp[i | state] = tmp dp[i | state] dp i | state i state tmp if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1]) dp[-1] == INF dp[-1] dp -1 INF print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input INF = float("inf") float("inf") INF def main():
    N, M = map(int, input().split())
    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = list(map(lambda x: int(x) - 1, input().split()))
        state = 0
        for c in C:
            state += 2 ** c
        key.append((a, state))
    dp = [INF for _ in range(2 ** N)]
    dp[0] = 0
    for i in range(2 ** N - 1):
        for k in range(M):
            state = key[k][1]
            tmp = dp[i] + key[k][0]
            if dp[i | state] > tmp:
                dp[i | state] = tmp
    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1]) def main():
    N, M = map(int, input().split())
    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = list(map(lambda x: int(x) - 1, input().split()))
        state = 0
        for c in C:
            state += 2 ** c
        key.append((a, state))
    dp = [INF for _ in range(2 ** N)]
    dp[0] = 0
    for i in range(2 ** N - 1):
        for k in range(M):
            state = key[k][1]
            tmp = dp[i] + key[k][0]
            if dp[i | state] > tmp:
                dp[i | state] = tmp
    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1]) main
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7
sys.setrecursionlimit(20000000)
INF = float("inf")


def main():
    N, M = map(int, input().split())
    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = list(map(lambda x: int(x) - 1, input().split()))
        state = 0
        for c in C:
            state += 2 ** c
        key.append((a, state))
    dp = [INF for _ in range(2 ** N)]
    dp[0] = 0
    for i in range(2 ** N - 1):
        for k in range(M):
            state = key[k][1]
            tmp = dp[i] + key[k][0]
            if dp[i | state] > tmp:
                dp[i | state] = tmp
    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1])


if __name__ == "__main__":
    main()
