import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = 10**8
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    key = [0]
    box = [0]
    for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
    if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1])
if __name__ == '__main__':
    main() import sys,queue,math,copy,itertools,bisect,collections,heapq sys queue math copy itertools bisect collections heapq def main():
    INF = 10**8
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    key = [0]
    box = [0]
    for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
    if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1]) main INF = 10**8 INF 10**8 10 8 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda : [int(x) for x in sys.stdin.readline().split()] LI lambda : [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] N,M = LI() N LI() LI M key = [0] key [0] 0 box = [0] box [0] 0 for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

     _ range(M) range M k,_ = LI() k LI() LI _ key.append(k) key.append key append k b = 0 b 0 for c in LI():
            b += 2**(c-1)
         c LI() LI b += 2**(c-1) b 2**(c-1) 2 c-1 c 1 box.append(b) box.append box append b [INF] * (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) [INF] * (2**N) [INF] INF 2**N 2 N dp = [[INF] * (2**N) for _ in range(M+1)] dp [[INF] * (2**N) for _ in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
     i range(1,M+1) range 1 M+1 M 1 for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
     j range(2**N) range 2**N 2 N dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i]) dp[i][j] [i] dp i j min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i]) min dp[i-1][j] [i-1] dp i-1 i 1 j dp[i-1][j - (j&box[i])]+key[i] dp[i-1][j - (j&box[i])] [i-1] dp i-1 i 1 j - (j&box[i]) j j&box[i] j box[i] box i key[i] key i if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1]) dp[-1][-1] == INF dp[-1][-1] [-1] dp -1 -1 INF print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    INF = 10**8
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    key = [0]
    box = [0]
    for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
    if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1]) def main():
    INF = 10**8
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    key = [0]
    box = [0]
    for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
    if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1]) main
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = 10**8
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    key = [0]
    box = [0]
    for _ in range(M):
        k,_ = LI()
        key.append(k)
        b = 0
        for c in LI():
            b += 2**(c-1)
        box.append(b)

    dp = [[INF] * (2**N) for _ in range(M+1)]
    dp[0][0] = 0
    for i in range(1,M+1):
        for j in range(2**N):
            dp[i][j] = min(dp[i-1][j],dp[i-1][j - (j&box[i])]+key[i])
    if dp[-1][-1] == INF:
        print(-1)
    else:
        print(dp[-1][-1])
if __name__ == '__main__':
    main()