import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
items = []
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    c = [int(x) for x in input().split()]
    c_ = sum([1 << (x - 1) for x in c])
    items.append([a, c_])

dp = [[float("inf")]*2**n for _ in range(m + 1)]
for i in range(m + 1):
    dp[i][0] = 0

for i in range(1, m + 1):
    a, c_ = items[i - 1]
    # 鍵を使わない
    for j in range(2**n):
        dp[i][j] = dp[i - 1][j]
    # 鍵を使うときと使わないときの比較
    for j in range(2**n):
        dp[i][j|c_] = min(dp[i][j|c_], dp[i - 1][j] + a)

ans = float("inf")

for i in range(1, m + 1):
    ans = min(ans, dp[i][-1])

if ans != float("inf"):
    print(ans)
else:
    print(-1) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x n, m = [int(x) for x in input().split()] n [int(x) for x in input().split()] m items = [] items [] for _ in range(m):
    a, b = [int(x) for x in input().split()]
    c = [int(x) for x in input().split()]
    c_ = sum([1 << (x - 1) for x in c])
    items.append([a, c_]) _ range(m) range m int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x a, b = [int(x) for x in input().split()] a [int(x) for x in input().split()] b int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x c = [int(x) for x in input().split()] c [int(x) for x in input().split()] 1 << (x - 1) for x in c for x in c x c for x in c 1 << (x - 1) 1 x - 1 x 1 c_ = sum([1 << (x - 1) for x in c]) c_ sum([1 << (x - 1) for x in c]) sum [1 << (x - 1) for x in c] items.append([a, c_]) items.append items append [a, c_] a c_ [float("inf")]*2**n for _ in range(m + 1) for _ in range(m + 1) _ range(m + 1) range m + 1 m 1 for _ in range(m + 1) [float("inf")]*2**n [float("inf")] float("inf") float "inf" 2**n 2 n dp = [[float("inf")]*2**n for _ in range(m + 1)] dp [[float("inf")]*2**n for _ in range(m + 1)] for i in range(m + 1):
    dp[i][0] = 0 i range(m + 1) range m + 1 m 1 dp[i][0] = 0 dp[i][0] [i] dp i 0 0 for i in range(1, m + 1):
    a, c_ = items[i - 1]
    # 鍵を使わない
    for j in range(2**n):
        dp[i][j] = dp[i - 1][j]
    # 鍵を使うときと使わないときの比較
    for j in range(2**n):
        dp[i][j|c_] = min(dp[i][j|c_], dp[i - 1][j] + a) i range(1, m + 1) range 1 m + 1 m 1 a, c_ = items[i - 1] a items[i - 1] items i - 1 i 1 c_ for j in range(2**n):
        dp[i][j] = dp[i - 1][j]
    # 鍵を使うときと使わないときの比較
     j range(2**n) range 2**n 2 n dp[i][j] = dp[i - 1][j] dp[i][j] [i] dp i j dp[i - 1][j] [i - 1] dp i - 1 i 1 j for j in range(2**n):
        dp[i][j|c_] = min(dp[i][j|c_], dp[i - 1][j] + a) j range(2**n) range 2**n 2 n dp[i][j|c_] = min(dp[i][j|c_], dp[i - 1][j] + a) dp[i][j|c_] [i] dp i j|c_ j c_ min(dp[i][j|c_], dp[i - 1][j] + a) min dp[i][j|c_] [i] dp i j|c_ j c_ dp[i - 1][j] + a dp[i - 1][j] [i - 1] dp i - 1 i 1 j a ans = float("inf") ans float("inf") float "inf" for i in range(1, m + 1):
    ans = min(ans, dp[i][-1]) i range(1, m + 1) range 1 m + 1 m 1 ans = min(ans, dp[i][-1]) ans min(ans, dp[i][-1]) min ans dp[i][-1] [i] dp i -1 if ans != float("inf"):
    print(ans)
else:
    print(-1) ans != float("inf") ans float("inf") float "inf" print(ans) print ans print(-1) print -1 c = [int(x) for x in input().split()] [int(x) for x in input().split()] c ans = min(ans, dp[i][-1]) min(ans, dp[i][-1]) ans a, c_ = items[i - 1] items[i - 1] a input = sys.stdin.readline sys.stdin.readline input items = [] [] items b = [int(x) for x in input().split()] [int(x) for x in input().split()] b c_ = sum([1 << (x - 1) for x in c]) sum([1 << (x - 1) for x in c]) c_ dp = [[float("inf")]*2**n for _ in range(m + 1)] [[float("inf")]*2**n for _ in range(m + 1)] dp m = [int(x) for x in input().split()] [int(x) for x in input().split()] m n, m = [int(x) for x in input().split()] [int(x) for x in input().split()] n c_ = items[i - 1] items[i - 1] c_ a, b = [int(x) for x in input().split()] [int(x) for x in input().split()] a ans = float("inf") float("inf") ans
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
items = []
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    c = [int(x) for x in input().split()]
    c_ = sum([1 << (x - 1) for x in c])
    items.append([a, c_])

dp = [[float("inf")]*2**n for _ in range(m + 1)]
for i in range(m + 1):
    dp[i][0] = 0

for i in range(1, m + 1):
    a, c_ = items[i - 1]
    # 鍵を使わない
    for j in range(2**n):
        dp[i][j] = dp[i - 1][j]
    # 鍵を使うときと使わないときの比較
    for j in range(2**n):
        dp[i][j|c_] = min(dp[i][j|c_], dp[i - 1][j] + a)

ans = float("inf")

for i in range(1, m + 1):
    ans = min(ans, dp[i][-1])

if ans != float("inf"):
    print(ans)
else:
    print(-1)