"""
bitDP
dp[j] => jの二進数表記で1になっている桁数と同じ番号の宝箱を全て開けるのに必要な費用の最小値
"""

N,M = map(int,input().split())
dp = [float("INF")]*(2**N)
dp[0] = 0
for _ in range(M):
    a,b = map(int,input().split())
    C = list(map(int,input().split()))
    key = 0
    for c in C:
        key += 1 << (c-1)
    for j in range(2**N-1,-1,-1):
        dp[j|key] = min(dp[j|key],dp[j]+a)

if dp[-1] == float("INF"):
    print(-1)
else:
    print(dp[-1])
 """
bitDP
dp[j] => jの二進数表記で1になっている桁数と同じ番号の宝箱を全て開けるのに必要な費用の最小値
""" N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M dp = [float("INF")]*(2**N) dp [float("INF")]*(2**N) [float("INF")] float("INF") float "INF" 2**N 2 N dp[0] = 0 dp[0] dp 0 0 for _ in range(M):
    a,b = map(int,input().split())
    C = list(map(int,input().split()))
    key = 0
    for c in C:
        key += 1 << (c-1)
    for j in range(2**N-1,-1,-1):
        dp[j|key] = min(dp[j|key],dp[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 C = list(map(int,input().split())) C list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split key = 0 key 0 for c in C:
        key += 1 << (c-1)
     c C key += 1 << (c-1) key 1 << (c-1) 1 c-1 c 1 for j in range(2**N-1,-1,-1):
        dp[j|key] = min(dp[j|key],dp[j]+a) j range(2**N-1,-1,-1) range 2**N-1 2**N 2 N 1 -1 -1 dp[j|key] = min(dp[j|key],dp[j]+a) dp[j|key] dp j|key j key min(dp[j|key],dp[j]+a) min dp[j|key] dp j|key j key dp[j]+a dp[j] dp j a if dp[-1] == float("INF"):
    print(-1)
else:
    print(dp[-1]) dp[-1] == float("INF") dp[-1] dp -1 float("INF") float "INF" print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M key = 0 0 key key += 1 << (c-1) 1 << (c-1) key dp = [float("INF")]*(2**N) [float("INF")]*(2**N) dp b = map(int,input().split()) map(int,input().split()) b C = list(map(int,input().split())) list(map(int,input().split())) C a,b = map(int,input().split()) map(int,input().split()) a
"""
bitDP
dp[j] => jの二進数表記で1になっている桁数と同じ番号の宝箱を全て開けるのに必要な費用の最小値
"""

N,M = map(int,input().split())
dp = [float("INF")]*(2**N)
dp[0] = 0
for _ in range(M):
    a,b = map(int,input().split())
    C = list(map(int,input().split()))
    key = 0
    for c in C:
        key += 1 << (c-1)
    for j in range(2**N-1,-1,-1):
        dp[j|key] = min(dp[j|key],dp[j]+a)

if dp[-1] == float("INF"):
    print(-1)
else:
    print(dp[-1])

