# e get everything
n, m = map(int, input().split())

lists = []
for i in range(m):
    price, num = map(int, input().split())
    K = list(map(int, input().split()))
    cnt = 0
    for some in K:
        cnt += 2**(n - some)
    lists.append((price, cnt))

dp = [[10**10 for i in range(2**n)]for j in range(m + 1)]
# dp[i][j]=i番目までの鍵を使用してjの状態を再現するために必要な最小の値
dp[0][0] = 0
for i in range(1, m + 1):
    price, mode = lists[i - 1][0], lists[i - 1][1]
    for j in range(2**n):
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j &(2**n-1-mode)] + price)

ans = dp[m][2**n - 1]

if ans < 10**10:
    print(ans)
else:
    print(-1) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m lists = [] lists [] for i in range(m):
    price, num = map(int, input().split())
    K = list(map(int, input().split()))
    cnt = 0
    for some in K:
        cnt += 2**(n - some)
    lists.append((price, cnt)) i range(m) range m price, num = map(int, input().split()) price map(int, input().split()) map int input().split() ().split () input split num K = list(map(int, input().split())) K list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cnt = 0 cnt 0 for some in K:
        cnt += 2**(n - some)
     some K cnt += 2**(n - some) cnt 2**(n - some) 2 n - some n some lists.append((price, cnt)) lists.append lists append (price, cnt) price cnt [10**10 for i in range(2**n)]for j in range(m + 1) for j in range(m + 1) j range(m + 1) range m + 1 m 1 for j in range(m + 1) [10**10 for i in range(2**n)] dp = [[10**10 for i in range(2**n)]for j in range(m + 1)] dp [[10**10 for i in range(2**n)]for j in range(m + 1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(1, m + 1):
    price, mode = lists[i - 1][0], lists[i - 1][1]
    for j in range(2**n):
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j &(2**n-1-mode)] + price) i range(1, m + 1) range 1 m + 1 m 1 price, mode = lists[i - 1][0], lists[i - 1][1] price lists[i - 1][0] [i - 1] lists i - 1 i 1 0 mode lists[i - 1][1] [i - 1] lists i - 1 i 1 1 for j in range(2**n):
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j &(2**n-1-mode)] + price) j range(2**n) range 2**n 2 n dp[i][j] = min(dp[i - 1][j], dp[i - 1][j &(2**n-1-mode)] + price) dp[i][j] [i] dp i j min(dp[i - 1][j], dp[i - 1][j &(2**n-1-mode)] + price) min dp[i - 1][j] [i - 1] dp i - 1 i 1 j dp[i - 1][j &(2**n-1-mode)] + price dp[i - 1][j &(2**n-1-mode)] [i - 1] dp i - 1 i 1 j &(2**n-1-mode) j 2**n-1-mode 2**n-1 2**n 2 n 1 mode price ans = dp[m][2**n - 1] ans dp[m][2**n - 1] [m] dp m 2**n - 1 2**n 2 n 1 if ans < 10**10:
    print(ans)
else:
    print(-1) ans < 10**10 ans 10**10 10 10 print(ans) print ans print(-1) print -1 lists = [] [] lists K = list(map(int, input().split())) list(map(int, input().split())) K num = map(int, input().split()) map(int, input().split()) num ans = dp[m][2**n - 1] dp[m][2**n - 1] ans n, m = map(int, input().split()) map(int, input().split()) n mode = lists[i - 1][0], lists[i - 1][1] lists[i - 1][1] mode m = map(int, input().split()) map(int, input().split()) m cnt = 0 0 cnt cnt += 2**(n - some) 2**(n - some) cnt price, mode = lists[i - 1][0], lists[i - 1][1] lists[i - 1][0] price price, num = map(int, input().split()) map(int, input().split()) price dp = [[10**10 for i in range(2**n)]for j in range(m + 1)] [[10**10 for i in range(2**n)]for j in range(m + 1)] dp
# e get everything
n, m = map(int, input().split())

lists = []
for i in range(m):
    price, num = map(int, input().split())
    K = list(map(int, input().split()))
    cnt = 0
    for some in K:
        cnt += 2**(n - some)
    lists.append((price, cnt))

dp = [[10**10 for i in range(2**n)]for j in range(m + 1)]
# dp[i][j]=i番目までの鍵を使用してjの状態を再現するために必要な最小の値
dp[0][0] = 0
for i in range(1, m + 1):
    price, mode = lists[i - 1][0], lists[i - 1][1]
    for j in range(2**n):
        dp[i][j] = min(dp[i - 1][j], dp[i - 1][j &(2**n-1-mode)] + price)

ans = dp[m][2**n - 1]

if ans < 10**10:
    print(ans)
else:
    print(-1)
