import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, M = map(int, input().split())
prices = [0] * M
ks = [0] * M
for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    prices[i] = a
    ks[i] = C

dp = [INF] * (1 << N)
dp[0] = 0
for i in range(M):
    key_bit = 0
    for k in ks[i]:
        key_bit |= 1 << (k - 1)
    for bit in range((1 << N) - 1, -1, -1):
        if dp[bit] != INF:
            nx_bit = bit | key_bit
            dp[nx_bit] = min(dp[nx_bit], dp[bit] + prices[i])
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])

 import sys sys import itertools itertools import time time import math math from heapq import heappop, heappush from collections import defaultdict from collections import Counter from collections import deque from itertools import permutations sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 INF = 10 ** 18 INF 10 ** 18 10 18 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M prices = [0] * M prices [0] * M [0] 0 M ks = [0] * M ks [0] * M [0] 0 M for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    prices[i] = a
    ks[i] = C i 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 prices[i] = a prices[i] prices i a ks[i] = C ks[i] ks i C dp = [INF] * (1 << N) dp [INF] * (1 << N) [INF] INF 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    key_bit = 0
    for k in ks[i]:
        key_bit |= 1 << (k - 1)
    for bit in range((1 << N) - 1, -1, -1):
        if dp[bit] != INF:
            nx_bit = bit | key_bit
            dp[nx_bit] = min(dp[nx_bit], dp[bit] + prices[i]) i range(M) range M key_bit = 0 key_bit 0 for k in ks[i]:
        key_bit |= 1 << (k - 1)
     k ks[i] ks i key_bit |= 1 << (k - 1) key_bit 1 << (k - 1) 1 k - 1 k 1 for bit in range((1 << N) - 1, -1, -1):
        if dp[bit] != INF:
            nx_bit = bit | key_bit
            dp[nx_bit] = min(dp[nx_bit], dp[bit] + prices[i]) bit range((1 << N) - 1, -1, -1) range (1 << N) - 1 1 << N 1 N 1 -1 -1 if dp[bit] != INF:
            nx_bit = bit | key_bit
            dp[nx_bit] = min(dp[nx_bit], dp[bit] + prices[i]) dp[bit] != INF dp[bit] dp bit INF nx_bit = bit | key_bit nx_bit bit | key_bit bit key_bit dp[nx_bit] = min(dp[nx_bit], dp[bit] + prices[i]) dp[nx_bit] dp nx_bit min(dp[nx_bit], dp[bit] + prices[i]) min dp[nx_bit] dp nx_bit dp[bit] + prices[i] dp[bit] dp bit prices[i] prices i if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1]) dp[-1] == INF dp[-1] dp -1 INF print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD a, b = map(int, input().split()) map(int, input().split()) a ks = [0] * M [0] * M ks dp = [INF] * (1 << N) [INF] * (1 << N) dp nx_bit = bit | key_bit bit | key_bit nx_bit C = list(map(int, input().split())) list(map(int, input().split())) C N, M = map(int, input().split()) map(int, input().split()) N readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline key_bit = 0 0 key_bit INF = 10 ** 18 10 ** 18 INF prices = [0] * M [0] * M prices key_bit |= 1 << (k - 1) 1 << (k - 1) key_bit M = map(int, input().split()) map(int, input().split()) M readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines read = sys.stdin.buffer.read sys.stdin.buffer.read read b = map(int, input().split()) map(int, input().split()) b
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, M = map(int, input().split())
prices = [0] * M
ks = [0] * M
for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    prices[i] = a
    ks[i] = C

dp = [INF] * (1 << N)
dp[0] = 0
for i in range(M):
    key_bit = 0
    for k in ks[i]:
        key_bit |= 1 << (k - 1)
    for bit in range((1 << N) - 1, -1, -1):
        if dp[bit] != INF:
            nx_bit = bit | key_bit
            dp[nx_bit] = min(dp[nx_bit], dp[bit] + prices[i])
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])


