#!usr/bin/env python3
import sys

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)


def main():
    N, M = map(int, input().split())
    keys = []
    for _ in range(M):
        a, b = map(int, input().split())
        bits = sum([1 << (i - 1) for i in map(int, input().split())])
        keys.append([a, bits])

    dp = [INF] * (2 ** N + 10)
    dp[0] = 0

    for i in range(M):
        for j in range(2 ** N):
            dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])
    print(dp[2 ** N - 1] if dp[2 ** N - 1] != INF else -1)


if __name__ == '__main__':
    main() import sys sys MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = 10 ** 18 INF 10 ** 18 10 18 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 sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 def main():
    N, M = map(int, input().split())
    keys = []
    for _ in range(M):
        a, b = map(int, input().split())
        bits = sum([1 << (i - 1) for i in map(int, input().split())])
        keys.append([a, bits])

    dp = [INF] * (2 ** N + 10)
    dp[0] = 0

    for i in range(M):
        for j in range(2 ** N):
            dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])
    print(dp[2 ** N - 1] if dp[2 ** N - 1] != INF else -1) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M keys = [] keys [] for _ in range(M):
        a, b = map(int, input().split())
        bits = sum([1 << (i - 1) for i in map(int, input().split())])
        keys.append([a, bits])

     _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b 1 << (i - 1) for i in map(int, input().split()) for i in map(int, input().split()) i map(int, input().split()) map int input().split() ().split () input split for i in map(int, input().split()) 1 << (i - 1) 1 i - 1 i 1 bits = sum([1 << (i - 1) for i in map(int, input().split())]) bits sum([1 << (i - 1) for i in map(int, input().split())]) sum [1 << (i - 1) for i in map(int, input().split())] keys.append([a, bits]) keys.append keys append [a, bits] a bits dp = [INF] * (2 ** N + 10) dp [INF] * (2 ** N + 10) [INF] INF 2 ** N + 10 2 ** N 2 N 10 dp[0] = 0 dp[0] dp 0 0 for i in range(M):
        for j in range(2 ** N):
            dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])
     i range(M) range M for j in range(2 ** N):
            dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])
     j range(2 ** N) range 2 ** N 2 N dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0]) dp[j | keys[i][1]] dp j | keys[i][1] j keys[i][1] [i] keys i 1 min(dp[j | keys[i][1]], dp[j] + keys[i][0]) min dp[j | keys[i][1]] dp j | keys[i][1] j keys[i][1] [i] keys i 1 dp[j] + keys[i][0] dp[j] dp j keys[i][0] [i] keys i 0 print(dp[2 ** N - 1] if dp[2 ** N - 1] != INF else -1) print dp[2 ** N - 1] if dp[2 ** N - 1] != INF else -1 dp[2 ** N - 1] != INF dp[2 ** N - 1] dp 2 ** N - 1 2 ** N 2 N 1 INF dp[2 ** N - 1] dp 2 ** N - 1 2 ** N 2 N 1 -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, M = map(int, input().split())
    keys = []
    for _ in range(M):
        a, b = map(int, input().split())
        bits = sum([1 << (i - 1) for i in map(int, input().split())])
        keys.append([a, bits])

    dp = [INF] * (2 ** N + 10)
    dp[0] = 0

    for i in range(M):
        for j in range(2 ** N):
            dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])
    print(dp[2 ** N - 1] if dp[2 ** N - 1] != INF else -1) def main():
    N, M = map(int, input().split())
    keys = []
    for _ in range(M):
        a, b = map(int, input().split())
        bits = sum([1 << (i - 1) for i in map(int, input().split())])
        keys.append([a, bits])

    dp = [INF] * (2 ** N + 10)
    dp[0] = 0

    for i in range(M):
        for j in range(2 ** N):
            dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])
    print(dp[2 ** N - 1] if dp[2 ** N - 1] != INF else -1) main input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INF = 10 ** 18 10 ** 18 INF
#!usr/bin/env python3
import sys

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)


def main():
    N, M = map(int, input().split())
    keys = []
    for _ in range(M):
        a, b = map(int, input().split())
        bits = sum([1 << (i - 1) for i in map(int, input().split())])
        keys.append([a, bits])

    dp = [INF] * (2 ** N + 10)
    dp[0] = 0

    for i in range(M):
        for j in range(2 ** N):
            dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])
    print(dp[2 ** N - 1] if dp[2 ** N - 1] != INF else -1)


if __name__ == '__main__':
    main()