import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    L = pow(2, N)
    Inf = pow(10, 20)
    Dist = [Inf] * L
    
    Dist[0] = 0
    for _ in range(M):
        a, b = map(int, input().split())
        bit = 0
        C = [int(c) for c in input().split()]
        for c in C: bit += pow(2, c-1)
        for k, d in enumerate(Dist):
            if d < Inf: Dist[k | bit] = min(Dist[k | bit], d + a)
            
    print(Dist[L - 1] if Dist[L-1] < Inf else -1)

    return 0

if __name__ == "__main__":
    solve() import sys sys def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    L = pow(2, N)
    Inf = pow(10, 20)
    Dist = [Inf] * L
    
    Dist[0] = 0
    for _ in range(M):
        a, b = map(int, input().split())
        bit = 0
        C = [int(c) for c in input().split()]
        for c in C: bit += pow(2, c-1)
        for k, d in enumerate(Dist):
            if d < Inf: Dist[k | bit] = min(Dist[k | bit], d + a)
            
    print(Dist[L - 1] if Dist[L-1] < Inf else -1)

    return 0 solve input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = pow(2, N) L pow(2, N) pow 2 N Inf = pow(10, 20) Inf pow(10, 20) pow 10 20 Dist = [Inf] * L Dist [Inf] * L [Inf] Inf L Dist[0] = 0 Dist[0] Dist 0 0 for _ in range(M):
        a, b = map(int, input().split())
        bit = 0
        C = [int(c) for c in input().split()]
        for c in C: bit += pow(2, c-1)
        for k, d in enumerate(Dist):
            if d < Inf: Dist[k | bit] = min(Dist[k | bit], d + a)
            
     _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b bit = 0 bit 0 int(c) for c in input().split() for c in input().split() c input().split() ().split () input split for c in input().split() int(c) int c C = [int(c) for c in input().split()] C [int(c) for c in input().split()] for c in C: bit += pow(2, c-1)
         c C for k, d in enumerate(Dist):
            if d < Inf: Dist[k | bit] = min(Dist[k | bit], d + a)
            
     k d enumerate(Dist) enumerate Dist if d < Inf: Dist[k | bit] = min(Dist[k | bit], d + a)
            
     d < Inf d Inf print(Dist[L - 1] if Dist[L-1] < Inf else -1) print Dist[L - 1] if Dist[L-1] < Inf else -1 Dist[L-1] < Inf Dist[L-1] Dist L-1 L 1 Inf Dist[L - 1] Dist L - 1 L 1 -1 return 0 0 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    L = pow(2, N)
    Inf = pow(10, 20)
    Dist = [Inf] * L
    
    Dist[0] = 0
    for _ in range(M):
        a, b = map(int, input().split())
        bit = 0
        C = [int(c) for c in input().split()]
        for c in C: bit += pow(2, c-1)
        for k, d in enumerate(Dist):
            if d < Inf: Dist[k | bit] = min(Dist[k | bit], d + a)
            
    print(Dist[L - 1] if Dist[L-1] < Inf else -1)

    return 0 def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    L = pow(2, N)
    Inf = pow(10, 20)
    Dist = [Inf] * L
    
    Dist[0] = 0
    for _ in range(M):
        a, b = map(int, input().split())
        bit = 0
        C = [int(c) for c in input().split()]
        for c in C: bit += pow(2, c-1)
        for k, d in enumerate(Dist):
            if d < Inf: Dist[k | bit] = min(Dist[k | bit], d + a)
            
    print(Dist[L - 1] if Dist[L-1] < Inf else -1)

    return 0 solve
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    L = pow(2, N)
    Inf = pow(10, 20)
    Dist = [Inf] * L
    
    Dist[0] = 0
    for _ in range(M):
        a, b = map(int, input().split())
        bit = 0
        C = [int(c) for c in input().split()]
        for c in C: bit += pow(2, c-1)
        for k, d in enumerate(Dist):
            if d < Inf: Dist[k | bit] = min(Dist[k | bit], d + a)
            
    print(Dist[L - 1] if Dist[L-1] < Inf else -1)

    return 0

if __name__ == "__main__":
    solve()