import sys
input = sys.stdin.readline
N, M = map(int, input().split())

INF = 1<<30
dp = [INF]*(1<<N)
dp[0] = 0

K = []
for _ in [0]*M:
    a, b = map(int, input().split())
    *C, = map(int, input().split())
    h = 0
    for c in C:
        h ^= 1 << (c-1)
    
    for i in range(1<<N):
        nxt = i|h
        dp[nxt] = min(dp[nxt], dp[i]+a)

ans = dp[(1<<N)-1]
print(-1 if ans == INF else ans) 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 INF = 1<<30 INF 1<<30 1 30 dp = [INF]*(1<<N) dp [INF]*(1<<N) [INF] INF 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 K = [] K [] for _ in [0]*M:
    a, b = map(int, input().split())
    *C, = map(int, input().split())
    h = 0
    for c in C:
        h ^= 1 << (c-1)
    
    for i in range(1<<N):
        nxt = i|h
        dp[nxt] = min(dp[nxt], dp[i]+a) _ [0]*M [0] 0 M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b *C, = map(int, input().split()) *C C map(int, input().split()) map int input().split() ().split () input split h = 0 h 0 for c in C:
        h ^= 1 << (c-1)
    
     c C h ^= 1 << (c-1) h 1 << (c-1) 1 c-1 c 1 for i in range(1<<N):
        nxt = i|h
        dp[nxt] = min(dp[nxt], dp[i]+a) i range(1<<N) range 1<<N 1 N nxt = i|h nxt i|h i h dp[nxt] = min(dp[nxt], dp[i]+a) dp[nxt] dp nxt min(dp[nxt], dp[i]+a) min dp[nxt] dp nxt dp[i]+a dp[i] dp i a ans = dp[(1<<N)-1] ans dp[(1<<N)-1] dp (1<<N)-1 1<<N 1 N 1 print(-1 if ans == INF else ans) print -1 if ans == INF else ans ans == INF ans INF -1 ans input = sys.stdin.readline sys.stdin.readline input N, M = map(int, input().split()) map(int, input().split()) N ans = dp[(1<<N)-1] dp[(1<<N)-1] ans b = map(int, input().split()) map(int, input().split()) b M = map(int, input().split()) map(int, input().split()) M h = 0 0 h h ^= 1 << (c-1) 1 << (c-1) h INF = 1<<30 1<<30 INF K = [] [] K dp = [INF]*(1<<N) [INF]*(1<<N) dp a, b = map(int, input().split()) map(int, input().split()) a nxt = i|h i|h nxt
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

INF = 1<<30
dp = [INF]*(1<<N)
dp[0] = 0

K = []
for _ in [0]*M:
    a, b = map(int, input().split())
    *C, = map(int, input().split())
    h = 0
    for c in C:
        h ^= 1 << (c-1)
    
    for i in range(1<<N):
        nxt = i|h
        dp[nxt] = min(dp[nxt], dp[i]+a)

ans = dp[(1<<N)-1]
print(-1 if ans == INF else ans)
