import sys
from collections import deque

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


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


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

    dp = [INF for i in range(1 << N)]
    dp[0] = 0

    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = tuple(map(lambda x: int(x) - 1, input().split()))
        status = 0
        for c in C:
            status += 2 ** c
        key.append((a, status))

    for a, status in key:
        if dp[status] > a:
            dp[status] = a

    for i in range(2 ** N - 1):
        for a, status in key:
            new_status = status | i
            if dp[new_status] > dp[i] + a:
                dp[new_status] = dp[i] + a

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


if __name__ == "__main__":
    main() import sys sys from collections import deque sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 INF = float("inf") INF float("inf") float "inf" MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 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 def main():
    N, M = map(int, input().split())

    dp = [INF for i in range(1 << N)]
    dp[0] = 0

    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = tuple(map(lambda x: int(x) - 1, input().split()))
        status = 0
        for c in C:
            status += 2 ** c
        key.append((a, status))

    for a, status in key:
        if dp[status] > a:
            dp[status] = a

    for i in range(2 ** N - 1):
        for a, status in key:
            new_status = status | i
            if dp[new_status] > dp[i] + a:
                dp[new_status] = dp[i] + a

    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 INF for i in range(1 << N) for i in range(1 << N) i range(1 << N) range 1 << N 1 N for i in range(1 << N) INF dp = [INF for i in range(1 << N)] dp [INF for i in range(1 << N)] dp[0] = 0 dp[0] dp 0 0 key = [] key [] for _ in range(M):
        a, b = map(int, input().split())
        C = tuple(map(lambda x: int(x) - 1, input().split()))
        status = 0
        for c in C:
            status += 2 ** c
        key.append((a, status))

     _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b C = tuple(map(lambda x: int(x) - 1, input().split())) C tuple(map(lambda x: int(x) - 1, input().split())) tuple 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 status = 0 status 0 for c in C:
            status += 2 ** c
         c C status += 2 ** c status 2 ** c 2 c key.append((a, status)) key.append key append (a, status) a status for a, status in key:
        if dp[status] > a:
            dp[status] = a

     a status key if dp[status] > a:
            dp[status] = a

     dp[status] > a dp[status] dp status a dp[status] = a dp[status] dp status a for i in range(2 ** N - 1):
        for a, status in key:
            new_status = status | i
            if dp[new_status] > dp[i] + a:
                dp[new_status] = dp[i] + a

     i range(2 ** N - 1) range 2 ** N - 1 2 ** N 2 N 1 for a, status in key:
            new_status = status | i
            if dp[new_status] > dp[i] + a:
                dp[new_status] = dp[i] + a

     a status key new_status = status | i new_status status | i status i if dp[new_status] > dp[i] + a:
                dp[new_status] = dp[i] + a

     dp[new_status] > dp[i] + a dp[new_status] dp new_status dp[i] + a dp[i] dp i a dp[new_status] = dp[i] + a dp[new_status] dp new_status dp[i] + a dp[i] dp i a 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 INF = float("inf") float("inf") INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def main():
    N, M = map(int, input().split())

    dp = [INF for i in range(1 << N)]
    dp[0] = 0

    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = tuple(map(lambda x: int(x) - 1, input().split()))
        status = 0
        for c in C:
            status += 2 ** c
        key.append((a, status))

    for a, status in key:
        if dp[status] > a:
            dp[status] = a

    for i in range(2 ** N - 1):
        for a, status in key:
            new_status = status | i
            if dp[new_status] > dp[i] + a:
                dp[new_status] = dp[i] + a

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

    dp = [INF for i in range(1 << N)]
    dp[0] = 0

    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = tuple(map(lambda x: int(x) - 1, input().split()))
        status = 0
        for c in C:
            status += 2 ** c
        key.append((a, status))

    for a, status in key:
        if dp[status] > a:
            dp[status] = a

    for i in range(2 ** N - 1):
        for a, status in key:
            new_status = status | i
            if dp[new_status] > dp[i] + a:
                dp[new_status] = dp[i] + a

    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1]) main def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input
import sys
from collections import deque

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


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


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

    dp = [INF for i in range(1 << N)]
    dp[0] = 0

    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = tuple(map(lambda x: int(x) - 1, input().split()))
        status = 0
        for c in C:
            status += 2 ** c
        key.append((a, status))

    for a, status in key:
        if dp[status] > a:
            dp[status] = a

    for i in range(2 ** N - 1):
        for a, status in key:
            new_status = status | i
            if dp[new_status] > dp[i] + a:
                dp[new_status] = dp[i] + a

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


if __name__ == "__main__":
    main()
