def main():
    n, m = map(int, input().split())
    all_patterns = 2**n
    DP = [10**9] * all_patterns
    DP[0] = 0
    for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)

        for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

    full_open = 2**n - 1
    ans = DP[full_open]
    if ans == 10 ** 9:
        ans = -1
        
    print(ans)


if __name__ == '__main__':
    main() def main():
    n, m = map(int, input().split())
    all_patterns = 2**n
    DP = [10**9] * all_patterns
    DP[0] = 0
    for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)

        for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

    full_open = 2**n - 1
    ans = DP[full_open]
    if ans == 10 ** 9:
        ans = -1
        
    print(ans) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m all_patterns = 2**n all_patterns 2**n 2 n DP = [10**9] * all_patterns DP [10**9] * all_patterns [10**9] 10**9 10 9 all_patterns DP[0] = 0 DP[0] DP 0 0 for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)

        for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

     _ range(m) range m cost, types = map(int, input().split()) cost map(int, input().split()) map int input().split() ().split () input split types to_open = list(map(int, input().split())) to_open list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split openable = 0 openable 0 for open in to_open:
            openable += 1 << (open-1)

         open to_open openable += 1 << (open-1) openable 1 << (open-1) 1 open-1 open 1 for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

     opened range(all_patterns) range all_patterns pattern = opened | openable pattern opened | openable opened openable new_cost = DP[opened] + cost new_cost DP[opened] + cost DP[opened] DP opened cost if DP[pattern] > new_cost:
                DP[pattern] = new_cost

     DP[pattern] > new_cost DP[pattern] DP pattern new_cost DP[pattern] = new_cost DP[pattern] DP pattern new_cost full_open = 2**n - 1 full_open 2**n - 1 2**n 2 n 1 ans = DP[full_open] ans DP[full_open] DP full_open if ans == 10 ** 9:
        ans = -1
        
     ans == 10 ** 9 ans 10 ** 9 10 9 ans = -1 ans -1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n, m = map(int, input().split())
    all_patterns = 2**n
    DP = [10**9] * all_patterns
    DP[0] = 0
    for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)

        for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

    full_open = 2**n - 1
    ans = DP[full_open]
    if ans == 10 ** 9:
        ans = -1
        
    print(ans) def main():
    n, m = map(int, input().split())
    all_patterns = 2**n
    DP = [10**9] * all_patterns
    DP[0] = 0
    for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)

        for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

    full_open = 2**n - 1
    ans = DP[full_open]
    if ans == 10 ** 9:
        ans = -1
        
    print(ans) main
def main():
    n, m = map(int, input().split())
    all_patterns = 2**n
    DP = [10**9] * all_patterns
    DP[0] = 0
    for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)

        for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

    full_open = 2**n - 1
    ans = DP[full_open]
    if ans == 10 ** 9:
        ans = -1
        
    print(ans)


if __name__ == '__main__':
    main()
