def main():
    n, m = map(int, input().split())
    keys = [[None for j in range(2)] for i in range(m)]
    for i in range(m):
        a, b = map(int, input().split())
        keys[i][0] = a
        keys[i][1] = 0
        c = list(map(int, input().split()))
        for j in c:
            keys[i][1] += int(pow(2, j-1))
    dp = [10**9 for i in range(int(pow(2, n)))]
    dp[0] = 0
    for i in range(int(pow(2, n))):
        for j in range(m):
            if dp[i | keys[j][1]] > dp[i] + keys[j][0]:
                dp[i | keys[j][1]] = dp[i] + keys[j][0]
    if dp[int(pow(2, n)) - 1] == 10**9:
        print("-1")
    else:
        print(dp[int(pow(2, n)) - 1])

if __name__ == "__main__":
    main() def main():
    n, m = map(int, input().split())
    keys = [[None for j in range(2)] for i in range(m)]
    for i in range(m):
        a, b = map(int, input().split())
        keys[i][0] = a
        keys[i][1] = 0
        c = list(map(int, input().split()))
        for j in c:
            keys[i][1] += int(pow(2, j-1))
    dp = [10**9 for i in range(int(pow(2, n)))]
    dp[0] = 0
    for i in range(int(pow(2, n))):
        for j in range(m):
            if dp[i | keys[j][1]] > dp[i] + keys[j][0]:
                dp[i | keys[j][1]] = dp[i] + keys[j][0]
    if dp[int(pow(2, n)) - 1] == 10**9:
        print("-1")
    else:
        print(dp[int(pow(2, n)) - 1]) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m [None for j in range(2)] for i in range(m) for i in range(m) i range(m) range m for i in range(m) [None for j in range(2)] keys = [[None for j in range(2)] for i in range(m)] keys [[None for j in range(2)] for i in range(m)] for i in range(m):
        a, b = map(int, input().split())
        keys[i][0] = a
        keys[i][1] = 0
        c = list(map(int, input().split()))
        for j in c:
            keys[i][1] += int(pow(2, j-1))
     i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b keys[i][0] = a keys[i][0] [i] keys i 0 a keys[i][1] = 0 keys[i][1] [i] keys i 1 0 c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for j in c:
            keys[i][1] += int(pow(2, j-1))
     j c keys[i][1] += int(pow(2, j-1)) keys[i][1] [i] keys i 1 int(pow(2, j-1)) int pow(2, j-1) pow 2 j-1 j 1 10**9 for i in range(int(pow(2, n))) for i in range(int(pow(2, n))) i range(int(pow(2, n))) range int(pow(2, n)) int pow(2, n) pow 2 n for i in range(int(pow(2, n))) 10**9 10 9 dp = [10**9 for i in range(int(pow(2, n)))] dp [10**9 for i in range(int(pow(2, n)))] dp[0] = 0 dp[0] dp 0 0 for i in range(int(pow(2, n))):
        for j in range(m):
            if dp[i | keys[j][1]] > dp[i] + keys[j][0]:
                dp[i | keys[j][1]] = dp[i] + keys[j][0]
     i range(int(pow(2, n))) range int(pow(2, n)) int pow(2, n) pow 2 n for j in range(m):
            if dp[i | keys[j][1]] > dp[i] + keys[j][0]:
                dp[i | keys[j][1]] = dp[i] + keys[j][0]
     j range(m) range m if dp[i | keys[j][1]] > dp[i] + keys[j][0]:
                dp[i | keys[j][1]] = dp[i] + keys[j][0]
     dp[i | keys[j][1]] > dp[i] + keys[j][0] dp[i | keys[j][1]] dp i | keys[j][1] i keys[j][1] [j] keys j 1 dp[i] + keys[j][0] dp[i] dp i keys[j][0] [j] keys j 0 dp[i | keys[j][1]] = dp[i] + keys[j][0] dp[i | keys[j][1]] dp i | keys[j][1] i keys[j][1] [j] keys j 1 dp[i] + keys[j][0] dp[i] dp i keys[j][0] [j] keys j 0 if dp[int(pow(2, n)) - 1] == 10**9:
        print("-1")
    else:
        print(dp[int(pow(2, n)) - 1]) dp[int(pow(2, n)) - 1] == 10**9 dp[int(pow(2, n)) - 1] dp int(pow(2, n)) - 1 int(pow(2, n)) int pow(2, n) pow 2 n 1 10**9 10 9 print("-1") print "-1" print(dp[int(pow(2, n)) - 1]) print dp[int(pow(2, n)) - 1] dp int(pow(2, n)) - 1 int(pow(2, n)) int pow(2, n) pow 2 n 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n, m = map(int, input().split())
    keys = [[None for j in range(2)] for i in range(m)]
    for i in range(m):
        a, b = map(int, input().split())
        keys[i][0] = a
        keys[i][1] = 0
        c = list(map(int, input().split()))
        for j in c:
            keys[i][1] += int(pow(2, j-1))
    dp = [10**9 for i in range(int(pow(2, n)))]
    dp[0] = 0
    for i in range(int(pow(2, n))):
        for j in range(m):
            if dp[i | keys[j][1]] > dp[i] + keys[j][0]:
                dp[i | keys[j][1]] = dp[i] + keys[j][0]
    if dp[int(pow(2, n)) - 1] == 10**9:
        print("-1")
    else:
        print(dp[int(pow(2, n)) - 1]) def main():
    n, m = map(int, input().split())
    keys = [[None for j in range(2)] for i in range(m)]
    for i in range(m):
        a, b = map(int, input().split())
        keys[i][0] = a
        keys[i][1] = 0
        c = list(map(int, input().split()))
        for j in c:
            keys[i][1] += int(pow(2, j-1))
    dp = [10**9 for i in range(int(pow(2, n)))]
    dp[0] = 0
    for i in range(int(pow(2, n))):
        for j in range(m):
            if dp[i | keys[j][1]] > dp[i] + keys[j][0]:
                dp[i | keys[j][1]] = dp[i] + keys[j][0]
    if dp[int(pow(2, n)) - 1] == 10**9:
        print("-1")
    else:
        print(dp[int(pow(2, n)) - 1]) main
def main():
    n, m = map(int, input().split())
    keys = [[None for j in range(2)] for i in range(m)]
    for i in range(m):
        a, b = map(int, input().split())
        keys[i][0] = a
        keys[i][1] = 0
        c = list(map(int, input().split()))
        for j in c:
            keys[i][1] += int(pow(2, j-1))
    dp = [10**9 for i in range(int(pow(2, n)))]
    dp[0] = 0
    for i in range(int(pow(2, n))):
        for j in range(m):
            if dp[i | keys[j][1]] > dp[i] + keys[j][0]:
                dp[i | keys[j][1]] = dp[i] + keys[j][0]
    if dp[int(pow(2, n)) - 1] == 10**9:
        print("-1")
    else:
        print(dp[int(pow(2, n)) - 1])

if __name__ == "__main__":
    main()