import sys
input = sys.stdin.readline

N, M = map(int, input().split())
ks = []

for _ in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    T = 0
    
    for ci in c:
        T += 1<<(ci-1)
    
    ks.append((a, T))

dp = [10**18]*(1<<N)
dp[0] = 0

for S in range(1<<N):
    for a, T in ks:
        dp[S|T] = min(dp[S|T], dp[S]+a)

if dp[-1]==10**18:
    print(-1)
else:
    print(dp[-1]) import sys sys 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 ks = [] ks [] for _ in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    T = 0
    
    for ci in c:
        T += 1<<(ci-1)
    
    ks.append((a, T)) _ 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 T = 0 T 0 for ci in c:
        T += 1<<(ci-1)
    
     ci c T += 1<<(ci-1) T 1<<(ci-1) 1 ci-1 ci 1 ks.append((a, T)) ks.append ks append (a, T) a T dp = [10**18]*(1<<N) dp [10**18]*(1<<N) [10**18] 10**18 10 18 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for S in range(1<<N):
    for a, T in ks:
        dp[S|T] = min(dp[S|T], dp[S]+a) S range(1<<N) range 1<<N 1 N for a, T in ks:
        dp[S|T] = min(dp[S|T], dp[S]+a) a T ks dp[S|T] = min(dp[S|T], dp[S]+a) dp[S|T] dp S|T S T min(dp[S|T], dp[S]+a) min dp[S|T] dp S|T S T dp[S]+a dp[S] dp S a if dp[-1]==10**18:
    print(-1)
else:
    print(dp[-1]) dp[-1]==10**18 dp[-1] dp -1 10**18 10 18 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 b = map(int, input().split()) map(int, input().split()) b input = sys.stdin.readline sys.stdin.readline input N, M = map(int, input().split()) map(int, input().split()) N c = list(map(int, input().split())) list(map(int, input().split())) c M = map(int, input().split()) map(int, input().split()) M T += 1<<(ci-1) 1<<(ci-1) T ks = [] [] ks dp = [10**18]*(1<<N) [10**18]*(1<<N) dp T = 0 0 T a, b = map(int, input().split()) map(int, input().split()) a
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
ks = []

for _ in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    T = 0
    
    for ci in c:
        T += 1<<(ci-1)
    
    ks.append((a, T))

dp = [10**18]*(1<<N)
dp[0] = 0

for S in range(1<<N):
    for a, T in ks:
        dp[S|T] = min(dp[S|T], dp[S]+a)

if dp[-1]==10**18:
    print(-1)
else:
    print(dp[-1])