def resolve():
    N, M = list(map(int, input().split()))
    costs = []
    openables = []
    for i in range(M):
        a, b = list(map(int, input().split()))
        costs.append(a)
        C = list(map(int, input().split()))
        state = 0
        for c in C:
            state += (1<<(c-1))
        openables.append(state)
    
    dp = [[float("inf") for _ in range(4100)] for __ in range(10**3+100)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1<<N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            opened_boxes = openables[i]
            dp[i+1][j|opened_boxes] = min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i])
    print(dp[M][(1<<N)-1] if dp[M][(1<<N)-1] < float("inf") else -1)

if __name__ == "__main__":
    resolve() def resolve():
    N, M = list(map(int, input().split()))
    costs = []
    openables = []
    for i in range(M):
        a, b = list(map(int, input().split()))
        costs.append(a)
        C = list(map(int, input().split()))
        state = 0
        for c in C:
            state += (1<<(c-1))
        openables.append(state)
    
    dp = [[float("inf") for _ in range(4100)] for __ in range(10**3+100)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1<<N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            opened_boxes = openables[i]
            dp[i+1][j|opened_boxes] = min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i])
    print(dp[M][(1<<N)-1] if dp[M][(1<<N)-1] < float("inf") else -1) resolve N, M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M costs = [] costs [] openables = [] openables [] for i in range(M):
        a, b = list(map(int, input().split()))
        costs.append(a)
        C = list(map(int, input().split()))
        state = 0
        for c in C:
            state += (1<<(c-1))
        openables.append(state)
    
     i range(M) range M a, b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split b costs.append(a) costs.append costs append a C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split state = 0 state 0 for c in C:
            state += (1<<(c-1))
         c C state += (1<<(c-1)) state 1<<(c-1) 1 c-1 c 1 openables.append(state) openables.append openables append state [float("inf") for _ in range(4100)] for __ in range(10**3+100) for __ in range(10**3+100) __ range(10**3+100) range 10**3+100 10**3 10 3 100 for __ in range(10**3+100) [float("inf") for _ in range(4100)] dp = [[float("inf") for _ in range(4100)] for __ in range(10**3+100)] dp [[float("inf") for _ in range(4100)] for __ in range(10**3+100)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
        for j in range(1<<N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            opened_boxes = openables[i]
            dp[i+1][j|opened_boxes] = min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i])
     i range(M) range M for j in range(1<<N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            opened_boxes = openables[i]
            dp[i+1][j|opened_boxes] = min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i])
     j range(1<<N) range 1<<N 1 N dp[i+1][j] = min(dp[i+1][j], dp[i][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i+1][j], dp[i][j]) min dp[i+1][j] [i+1] dp i+1 i 1 j dp[i][j] [i] dp i j opened_boxes = openables[i] opened_boxes openables[i] openables i dp[i+1][j|opened_boxes] = min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i]) dp[i+1][j|opened_boxes] [i+1] dp i+1 i 1 j|opened_boxes j opened_boxes min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i]) min dp[i+1][j|opened_boxes] [i+1] dp i+1 i 1 j|opened_boxes j opened_boxes dp[i][j]+costs[i] dp[i][j] [i] dp i j costs[i] costs i print(dp[M][(1<<N)-1] if dp[M][(1<<N)-1] < float("inf") else -1) print dp[M][(1<<N)-1] if dp[M][(1<<N)-1] < float("inf") else -1 dp[M][(1<<N)-1] < float("inf") dp[M][(1<<N)-1] [M] dp M (1<<N)-1 1<<N 1 N 1 float("inf") float "inf" dp[M][(1<<N)-1] [M] dp M (1<<N)-1 1<<N 1 N 1 -1 if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    N, M = list(map(int, input().split()))
    costs = []
    openables = []
    for i in range(M):
        a, b = list(map(int, input().split()))
        costs.append(a)
        C = list(map(int, input().split()))
        state = 0
        for c in C:
            state += (1<<(c-1))
        openables.append(state)
    
    dp = [[float("inf") for _ in range(4100)] for __ in range(10**3+100)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1<<N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            opened_boxes = openables[i]
            dp[i+1][j|opened_boxes] = min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i])
    print(dp[M][(1<<N)-1] if dp[M][(1<<N)-1] < float("inf") else -1) def resolve():
    N, M = list(map(int, input().split()))
    costs = []
    openables = []
    for i in range(M):
        a, b = list(map(int, input().split()))
        costs.append(a)
        C = list(map(int, input().split()))
        state = 0
        for c in C:
            state += (1<<(c-1))
        openables.append(state)
    
    dp = [[float("inf") for _ in range(4100)] for __ in range(10**3+100)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1<<N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            opened_boxes = openables[i]
            dp[i+1][j|opened_boxes] = min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i])
    print(dp[M][(1<<N)-1] if dp[M][(1<<N)-1] < float("inf") else -1) resolve
def resolve():
    N, M = list(map(int, input().split()))
    costs = []
    openables = []
    for i in range(M):
        a, b = list(map(int, input().split()))
        costs.append(a)
        C = list(map(int, input().split()))
        state = 0
        for c in C:
            state += (1<<(c-1))
        openables.append(state)
    
    dp = [[float("inf") for _ in range(4100)] for __ in range(10**3+100)]
    dp[0][0] = 0
    for i in range(M):
        for j in range(1<<N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            opened_boxes = openables[i]
            dp[i+1][j|opened_boxes] = min(dp[i+1][j|opened_boxes], dp[i][j]+costs[i])
    print(dp[M][(1<<N)-1] if dp[M][(1<<N)-1] < float("inf") else -1)

if __name__ == "__main__":
    resolve()