N,M = (int(x) for x in input().split())
abc = [[None] * 3 for _ in range(M)]
check = set()
for x in abc:
    x[0],x[1] = (int(x) for x in input().split())
    x[2] = list(map(int, input().split()))
    check = check | set(x[2])
if len(check) < N:
    print('-1')
else:
    a = [x[0] for x in abc]
    c = [0] * (M+1)
    dp = [[float('inf')] * pow(2,N) for _ in range(M+1)]
    for i in range(1,M+1):
        c[i] = sum(pow(2,y-1) for y in abc[i-1][2])
    for i in range(M+1):
        dp[i][0] = 0
    for i in range(1,M+1):
        for j in range(pow(2,N)):
            dp[i][j] = min(dp[i][j],dp[i-1][j])
            dp[i][j|c[i]] = min(dp[i][j|c[i]],dp[i][j]+a[i-1])
    print(dp[M][pow(2,N)-1]) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x N,M = (int(x) for x in input().split()) N (int(x) for x in input().split()) M [None] * 3 for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [None] * 3 [None] None 3 abc = [[None] * 3 for _ in range(M)] abc [[None] * 3 for _ in range(M)] check = set() check set() set for x in abc:
    x[0],x[1] = (int(x) for x in input().split())
    x[2] = list(map(int, input().split()))
    check = check | set(x[2]) x abc int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x x[0],x[1] = (int(x) for x in input().split()) x[0] x 0 (int(x) for x in input().split()) x[1] x 1 x[2] = list(map(int, input().split())) x[2] x 2 list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split check = check | set(x[2]) check check | set(x[2]) check set(x[2]) set x[2] x 2 if len(check) < N:
    print('-1')
else:
    a = [x[0] for x in abc]
    c = [0] * (M+1)
    dp = [[float('inf')] * pow(2,N) for _ in range(M+1)]
    for i in range(1,M+1):
        c[i] = sum(pow(2,y-1) for y in abc[i-1][2])
    for i in range(M+1):
        dp[i][0] = 0
    for i in range(1,M+1):
        for j in range(pow(2,N)):
            dp[i][j] = min(dp[i][j],dp[i-1][j])
            dp[i][j|c[i]] = min(dp[i][j|c[i]],dp[i][j]+a[i-1])
    print(dp[M][pow(2,N)-1]) len(check) < N len(check) len check N print('-1') print '-1' x[0] for x in abc for x in abc x abc for x in abc x[0] x 0 a = [x[0] for x in abc] a [x[0] for x in abc] c = [0] * (M+1) c [0] * (M+1) [0] 0 M+1 M 1 [float('inf')] * pow(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) [float('inf')] * pow(2,N) [float('inf')] float('inf') float 'inf' pow(2,N) pow 2 N dp = [[float('inf')] * pow(2,N) for _ in range(M+1)] dp [[float('inf')] * pow(2,N) for _ in range(M+1)] for i in range(1,M+1):
        c[i] = sum(pow(2,y-1) for y in abc[i-1][2])
     i range(1,M+1) range 1 M+1 M 1 c[i] = sum(pow(2,y-1) for y in abc[i-1][2]) c[i] c i sum(pow(2,y-1) for y in abc[i-1][2]) sum pow(2,y-1) pow 2 y-1 y 1 for i in range(M+1):
        dp[i][0] = 0
     i range(M+1) range M+1 M 1 dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for i in range(1,M+1):
        for j in range(pow(2,N)):
            dp[i][j] = min(dp[i][j],dp[i-1][j])
            dp[i][j|c[i]] = min(dp[i][j|c[i]],dp[i][j]+a[i-1])
     i range(1,M+1) range 1 M+1 M 1 for j in range(pow(2,N)):
            dp[i][j] = min(dp[i][j],dp[i-1][j])
            dp[i][j|c[i]] = min(dp[i][j|c[i]],dp[i][j]+a[i-1])
     j range(pow(2,N)) range pow(2,N) pow 2 N dp[i][j] = min(dp[i][j],dp[i-1][j]) dp[i][j] [i] dp i j min(dp[i][j],dp[i-1][j]) min dp[i][j] [i] dp i j dp[i-1][j] [i-1] dp i-1 i 1 j dp[i][j|c[i]] = min(dp[i][j|c[i]],dp[i][j]+a[i-1]) dp[i][j|c[i]] [i] dp i j|c[i] j c[i] c i min(dp[i][j|c[i]],dp[i][j]+a[i-1]) min dp[i][j|c[i]] [i] dp i j|c[i] j c[i] c i dp[i][j]+a[i-1] dp[i][j] [i] dp i j a[i-1] a i-1 i 1 print(dp[M][pow(2,N)-1]) print dp[M][pow(2,N)-1] [M] dp M pow(2,N)-1 pow(2,N) pow 2 N 1 c = [0] * (M+1) [0] * (M+1) c N,M = (int(x) for x in input().split()) (int(x) for x in input().split()) N M = (int(x) for x in input().split()) (int(x) for x in input().split()) M abc = [[None] * 3 for _ in range(M)] [[None] * 3 for _ in range(M)] abc a = [x[0] for x in abc] [x[0] for x in abc] a dp = [[float('inf')] * pow(2,N) for _ in range(M+1)] [[float('inf')] * pow(2,N) for _ in range(M+1)] dp check = set() set() check check = check | set(x[2]) check | set(x[2]) check
N,M = (int(x) for x in input().split())
abc = [[None] * 3 for _ in range(M)]
check = set()
for x in abc:
    x[0],x[1] = (int(x) for x in input().split())
    x[2] = list(map(int, input().split()))
    check = check | set(x[2])
if len(check) < N:
    print('-1')
else:
    a = [x[0] for x in abc]
    c = [0] * (M+1)
    dp = [[float('inf')] * pow(2,N) for _ in range(M+1)]
    for i in range(1,M+1):
        c[i] = sum(pow(2,y-1) for y in abc[i-1][2])
    for i in range(M+1):
        dp[i][0] = 0
    for i in range(1,M+1):
        for j in range(pow(2,N)):
            dp[i][j] = min(dp[i][j],dp[i-1][j])
            dp[i][j|c[i]] = min(dp[i][j|c[i]],dp[i][j]+a[i-1])
    print(dp[M][pow(2,N)-1])