import sys

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

    return 0

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

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

    return 0 solve
import sys

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

    return 0

if __name__ == "__main__":
    solve()