N, M = map(int, input().split())
a = []
b = []
c = []

MY_INF = 1000000007

for _ in range(M):
    a_tmp, b_tmp = map(int, input().split())
    a.append(a_tmp)
    b.append(b_tmp)
    c.append(list(map(int, input().split())))

c_bin = []
for i in range(M):
    c_bin.append(sum([1 << (cij - 1) for cij in c[i]]))
    
memo = [None] * (1 << N)

def dp(state):
    global MY_INF
    if state == (1 << N) - 1: return 0
    if memo[state] != None: return memo[state]
    #
    rets = [MY_INF]
    for i in range(M):
        if (state | c_bin[i]) > state:
            rets.append(a[i] + dp((state | c_bin[i])))
    ret = min(rets)
    #
    memo[state] = ret
    return ret

ans = dp(0)
if ans != MY_INF:
    print(ans)
else:
    print(-1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M a = [] a [] b = [] b [] c = [] c [] MY_INF = 1000000007 MY_INF 1000000007 for _ in range(M):
    a_tmp, b_tmp = map(int, input().split())
    a.append(a_tmp)
    b.append(b_tmp)
    c.append(list(map(int, input().split()))) _ range(M) range M a_tmp, b_tmp = map(int, input().split()) a_tmp map(int, input().split()) map int input().split() ().split () input split b_tmp a.append(a_tmp) a.append a append a_tmp b.append(b_tmp) b.append b append b_tmp c.append(list(map(int, input().split()))) c.append c append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c_bin = [] c_bin [] for i in range(M):
    c_bin.append(sum([1 << (cij - 1) for cij in c[i]]))
     i range(M) range M 1 << (cij - 1) for cij in c[i] for cij in c[i] cij c[i] c i for cij in c[i] 1 << (cij - 1) 1 cij - 1 cij 1 c_bin.append(sum([1 << (cij - 1) for cij in c[i]])) c_bin.append c_bin append sum([1 << (cij - 1) for cij in c[i]]) sum [1 << (cij - 1) for cij in c[i]] memo = [None] * (1 << N) memo [None] * (1 << N) [None] None 1 << N 1 N def dp(state):
    global MY_INF
    if state == (1 << N) - 1: return 0
    if memo[state] != None: return memo[state]
    #
    rets = [MY_INF]
    for i in range(M):
        if (state | c_bin[i]) > state:
            rets.append(a[i] + dp((state | c_bin[i])))
    ret = min(rets)
    #
    memo[state] = ret
    return ret dp global MY_INF if state == (1 << N) - 1: return 0
     state == (1 << N) - 1 state (1 << N) - 1 1 << N 1 N 1 if memo[state] != None: return memo[state]
    #
     memo[state] != None memo[state] memo state None rets = [MY_INF] rets [MY_INF] MY_INF for i in range(M):
        if (state | c_bin[i]) > state:
            rets.append(a[i] + dp((state | c_bin[i])))
     i range(M) range M if (state | c_bin[i]) > state:
            rets.append(a[i] + dp((state | c_bin[i])))
     (state | c_bin[i]) > state state | c_bin[i] state c_bin[i] c_bin i state rets.append(a[i] + dp((state | c_bin[i]))) rets.append rets append a[i] + dp((state | c_bin[i])) a[i] a i dp((state | c_bin[i])) dp state | c_bin[i] state c_bin[i] c_bin i ret = min(rets) ret min(rets) min rets memo[state] = ret memo[state] memo state ret return ret ret state state ans = dp(0) ans dp(0) dp 0 if ans != MY_INF:
    print(ans)
else:
    print(-1) ans != MY_INF ans MY_INF print(ans) print ans print(-1) print -1 N, M = map(int, input().split()) map(int, input().split()) N a = [] [] a c_bin = [] [] c_bin b = [] [] b b_tmp = map(int, input().split()) map(int, input().split()) b_tmp MY_INF = 1000000007 1000000007 MY_INF memo = [None] * (1 << N) [None] * (1 << N) memo ans = dp(0) dp(0) ans def dp(state):
    global MY_INF
    if state == (1 << N) - 1: return 0
    if memo[state] != None: return memo[state]
    #
    rets = [MY_INF]
    for i in range(M):
        if (state | c_bin[i]) > state:
            rets.append(a[i] + dp((state | c_bin[i])))
    ret = min(rets)
    #
    memo[state] = ret
    return ret def dp(state):
    global MY_INF
    if state == (1 << N) - 1: return 0
    if memo[state] != None: return memo[state]
    #
    rets = [MY_INF]
    for i in range(M):
        if (state | c_bin[i]) > state:
            rets.append(a[i] + dp((state | c_bin[i])))
    ret = min(rets)
    #
    memo[state] = ret
    return ret dp a_tmp, b_tmp = map(int, input().split()) map(int, input().split()) a_tmp M = map(int, input().split()) map(int, input().split()) M c = [] [] c
N, M = map(int, input().split())
a = []
b = []
c = []

MY_INF = 1000000007

for _ in range(M):
    a_tmp, b_tmp = map(int, input().split())
    a.append(a_tmp)
    b.append(b_tmp)
    c.append(list(map(int, input().split())))

c_bin = []
for i in range(M):
    c_bin.append(sum([1 << (cij - 1) for cij in c[i]]))
    
memo = [None] * (1 << N)

def dp(state):
    global MY_INF
    if state == (1 << N) - 1: return 0
    if memo[state] != None: return memo[state]
    #
    rets = [MY_INF]
    for i in range(M):
        if (state | c_bin[i]) > state:
            rets.append(a[i] + dp((state | c_bin[i])))
    ret = min(rets)
    #
    memo[state] = ret
    return ret

ans = dp(0)
if ans != MY_INF:
    print(ans)
else:
    print(-1)