import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, M = NMI()
    keys = {}
    for i in range(M):
        a, b = NMI()
        C = NLI()
        case = 0
        for c in C:
            case += 2**(c-1)
        keys[i+1] = (a, case)

    dp = [[10**10] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0

    for key in range(0, M):
        for case in range(2**N):
            if dp[key][case] == 10**10:
                continue
            next_case = case | keys[key+1][1]
            dp[key+1][next_case] = min(dp[key][case] + keys[key+1][0], dp[key+1][next_case])
            dp[key+1][case] = min(dp[key][case], dp[key+1][case])
    ans = dp[M][2**N-1]
    print(ans if ans < 10**10 else -1)






if __name__ == "__main__":
    main() import sys sys import math math from collections import deque sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip NI = lambda: int(input()) NI lambda: int(input()) int(input()) int input() input NMI = lambda: map(int, input().split()) NMI lambda: map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split NLI = lambda: list(NMI()) NLI lambda: list(NMI()) list(NMI()) list NMI() NMI SI = lambda: input() SI lambda: input() input() input [int(num)] * w for _ in range(h) for _ in range(h) _ range(h) range h for _ in range(h) [int(num)] * w [int(num)] int(num) int num w def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] make_grid h h w w num num def main():
    N, M = NMI()
    keys = {}
    for i in range(M):
        a, b = NMI()
        C = NLI()
        case = 0
        for c in C:
            case += 2**(c-1)
        keys[i+1] = (a, case)

    dp = [[10**10] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0

    for key in range(0, M):
        for case in range(2**N):
            if dp[key][case] == 10**10:
                continue
            next_case = case | keys[key+1][1]
            dp[key+1][next_case] = min(dp[key][case] + keys[key+1][0], dp[key+1][next_case])
            dp[key+1][case] = min(dp[key][case], dp[key+1][case])
    ans = dp[M][2**N-1]
    print(ans if ans < 10**10 else -1) main N, M = NMI() N NMI() NMI M keys = {} keys {} for i in range(M):
        a, b = NMI()
        C = NLI()
        case = 0
        for c in C:
            case += 2**(c-1)
        keys[i+1] = (a, case)

     i range(M) range M a, b = NMI() a NMI() NMI b C = NLI() C NLI() NLI case = 0 case 0 for c in C:
            case += 2**(c-1)
         c C case += 2**(c-1) case 2**(c-1) 2 c-1 c 1 keys[i+1] = (a, case) keys[i+1] keys i+1 i 1 (a, case) a case [10**10] * (2**N) for _ in range(M+1) for _ in range(M+1) _ range(M+1) range M+1 M 1 for _ in range(M+1) [10**10] * (2**N) [10**10] 10**10 10 10 2**N 2 N dp = [[10**10] * (2**N) for _ in range(M+1)] dp [[10**10] * (2**N) for _ in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for key in range(0, M):
        for case in range(2**N):
            if dp[key][case] == 10**10:
                continue
            next_case = case | keys[key+1][1]
            dp[key+1][next_case] = min(dp[key][case] + keys[key+1][0], dp[key+1][next_case])
            dp[key+1][case] = min(dp[key][case], dp[key+1][case])
     key range(0, M) range 0 M for case in range(2**N):
            if dp[key][case] == 10**10:
                continue
            next_case = case | keys[key+1][1]
            dp[key+1][next_case] = min(dp[key][case] + keys[key+1][0], dp[key+1][next_case])
            dp[key+1][case] = min(dp[key][case], dp[key+1][case])
     case range(2**N) range 2**N 2 N if dp[key][case] == 10**10:
                continue
             dp[key][case] == 10**10 dp[key][case] [key] dp key case 10**10 10 10 continue next_case = case | keys[key+1][1] next_case case | keys[key+1][1] case keys[key+1][1] [key+1] keys key+1 key 1 1 dp[key+1][next_case] = min(dp[key][case] + keys[key+1][0], dp[key+1][next_case]) dp[key+1][next_case] [key+1] dp key+1 key 1 next_case min(dp[key][case] + keys[key+1][0], dp[key+1][next_case]) min dp[key][case] + keys[key+1][0] dp[key][case] [key] dp key case keys[key+1][0] [key+1] keys key+1 key 1 0 dp[key+1][next_case] [key+1] dp key+1 key 1 next_case dp[key+1][case] = min(dp[key][case], dp[key+1][case]) dp[key+1][case] [key+1] dp key+1 key 1 case min(dp[key][case], dp[key+1][case]) min dp[key][case] [key] dp key case dp[key+1][case] [key+1] dp key+1 key 1 case ans = dp[M][2**N-1] ans dp[M][2**N-1] [M] dp M 2**N-1 2**N 2 N 1 print(ans if ans < 10**10 else -1) print ans if ans < 10**10 else -1 ans < 10**10 ans 10**10 10 10 ans -1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] make_grid MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input SI = lambda: input() lambda: input() SI def main():
    N, M = NMI()
    keys = {}
    for i in range(M):
        a, b = NMI()
        C = NLI()
        case = 0
        for c in C:
            case += 2**(c-1)
        keys[i+1] = (a, case)

    dp = [[10**10] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0

    for key in range(0, M):
        for case in range(2**N):
            if dp[key][case] == 10**10:
                continue
            next_case = case | keys[key+1][1]
            dp[key+1][next_case] = min(dp[key][case] + keys[key+1][0], dp[key+1][next_case])
            dp[key+1][case] = min(dp[key][case], dp[key+1][case])
    ans = dp[M][2**N-1]
    print(ans if ans < 10**10 else -1) def main():
    N, M = NMI()
    keys = {}
    for i in range(M):
        a, b = NMI()
        C = NLI()
        case = 0
        for c in C:
            case += 2**(c-1)
        keys[i+1] = (a, case)

    dp = [[10**10] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0

    for key in range(0, M):
        for case in range(2**N):
            if dp[key][case] == 10**10:
                continue
            next_case = case | keys[key+1][1]
            dp[key+1][next_case] = min(dp[key][case] + keys[key+1][0], dp[key+1][next_case])
            dp[key+1][case] = min(dp[key][case], dp[key+1][case])
    ans = dp[M][2**N-1]
    print(ans if ans < 10**10 else -1) main NLI = lambda: list(NMI()) lambda: list(NMI()) NLI NMI = lambda: map(int, input().split()) lambda: map(int, input().split()) NMI NI = lambda: int(input()) lambda: int(input()) NI
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, M = NMI()
    keys = {}
    for i in range(M):
        a, b = NMI()
        C = NLI()
        case = 0
        for c in C:
            case += 2**(c-1)
        keys[i+1] = (a, case)

    dp = [[10**10] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0

    for key in range(0, M):
        for case in range(2**N):
            if dp[key][case] == 10**10:
                continue
            next_case = case | keys[key+1][1]
            dp[key+1][next_case] = min(dp[key][case] + keys[key+1][0], dp[key+1][next_case])
            dp[key+1][case] = min(dp[key][case], dp[key+1][case])
    ans = dp[M][2**N-1]
    print(ans if ans < 10**10 else -1)






if __name__ == "__main__":
    main()