N,M=map(int,input().split())
dp=[float("inf") for _ in range(2**N)]
dp[0]=0
for _ in range(M):
    a,b=map(int,input().split())
    c=sum([2**(int(i)-1) for i in input().split()])
    for v in range(2**N):
        nv=v|c
        dp[nv]=min(dp[nv],dp[v]+a)
if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1]) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M float("inf") for _ in range(2**N) for _ in range(2**N) _ range(2**N) range 2**N 2 N for _ in range(2**N) float("inf") float "inf" dp=[float("inf") for _ in range(2**N)] dp [float("inf") for _ in range(2**N)] dp[0]=0 dp[0] dp 0 0 for _ in range(M):
    a,b=map(int,input().split())
    c=sum([2**(int(i)-1) for i in input().split()])
    for v in range(2**N):
        nv=v|c
        dp[nv]=min(dp[nv],dp[v]+a) _ range(M) range M a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b 2**(int(i)-1) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() 2**(int(i)-1) 2 int(i)-1 int(i) int i 1 c=sum([2**(int(i)-1) for i in input().split()]) c sum([2**(int(i)-1) for i in input().split()]) sum [2**(int(i)-1) for i in input().split()] for v in range(2**N):
        nv=v|c
        dp[nv]=min(dp[nv],dp[v]+a) v range(2**N) range 2**N 2 N nv=v|c nv v|c v c dp[nv]=min(dp[nv],dp[v]+a) dp[nv] dp nv min(dp[nv],dp[v]+a) min dp[nv] dp nv dp[v]+a dp[v] dp v 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 a,b=map(int,input().split()) map(int,input().split()) a nv=v|c v|c nv dp=[float("inf") for _ in range(2**N)] [float("inf") for _ in range(2**N)] dp M=map(int,input().split()) map(int,input().split()) M c=sum([2**(int(i)-1) for i in input().split()]) sum([2**(int(i)-1) for i in input().split()]) c N,M=map(int,input().split()) map(int,input().split()) N b=map(int,input().split()) map(int,input().split()) b
N,M=map(int,input().split())
dp=[float("inf") for _ in range(2**N)]
dp[0]=0
for _ in range(M):
    a,b=map(int,input().split())
    c=sum([2**(int(i)-1) for i in input().split()])
    for v in range(2**N):
        nv=v|c
        dp[nv]=min(dp[nv],dp[v]+a)
if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1])