n , m = map(int,input().split())
kagi = []
for i in range(m):
    a , b = map(int,input().split())
    c = list(map(lambda x:int(x)-1,input().split()))
    k = 0
    for j in c:
        k += 2**j
    kagi.append((a,k))
dp = [[float("inf") for i in range(2**n)] for j in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for j in range(2**n):
        dp[i+1][j] = min(dp[i][j],dp[i+1][j])
        dp[i+1][j | kagi[i][1]] = min(dp[i+1][j | kagi[i][1]],dp[i][j] + kagi[i][0])

if dp[-1][-1] != float("inf"):
    print(dp[-1][-1])
else:
    print(-1) n , m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m kagi = [] kagi [] for i in range(m):
    a , b = map(int,input().split())
    c = list(map(lambda x:int(x)-1,input().split()))
    k = 0
    for j in c:
        k += 2**j
    kagi.append((a,k)) 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(lambda x:int(x)-1,input().split())) c list(map(lambda x:int(x)-1,input().split())) list map(lambda x:int(x)-1,input().split()) map lambda x:int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split k = 0 k 0 for j in c:
        k += 2**j
     j c k += 2**j k 2**j 2 j kagi.append((a,k)) kagi.append kagi append (a,k) a k [float("inf") 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) [float("inf") for i in range(2**n)] dp = [[float("inf") for i in range(2**n)] for j in range(m+1)] dp [[float("inf") 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(m):
    for j in range(2**n):
        dp[i+1][j] = min(dp[i][j],dp[i+1][j])
        dp[i+1][j | kagi[i][1]] = min(dp[i+1][j | kagi[i][1]],dp[i][j] + kagi[i][0]) i range(m) range m for j in range(2**n):
        dp[i+1][j] = min(dp[i][j],dp[i+1][j])
        dp[i+1][j | kagi[i][1]] = min(dp[i+1][j | kagi[i][1]],dp[i][j] + kagi[i][0]) j range(2**n) range 2**n 2 n dp[i+1][j] = min(dp[i][j],dp[i+1][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i][j],dp[i+1][j]) min dp[i][j] [i] dp i j dp[i+1][j] [i+1] dp i+1 i 1 j dp[i+1][j | kagi[i][1]] = min(dp[i+1][j | kagi[i][1]],dp[i][j] + kagi[i][0]) dp[i+1][j | kagi[i][1]] [i+1] dp i+1 i 1 j | kagi[i][1] j kagi[i][1] [i] kagi i 1 min(dp[i+1][j | kagi[i][1]],dp[i][j] + kagi[i][0]) min dp[i+1][j | kagi[i][1]] [i+1] dp i+1 i 1 j | kagi[i][1] j kagi[i][1] [i] kagi i 1 dp[i][j] + kagi[i][0] dp[i][j] [i] dp i j kagi[i][0] [i] kagi i 0 if dp[-1][-1] != float("inf"):
    print(dp[-1][-1])
else:
    print(-1) dp[-1][-1] != float("inf") dp[-1][-1] [-1] dp -1 -1 float("inf") float "inf" print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 print(-1) print -1 a , b = map(int,input().split()) map(int,input().split()) a m = map(int,input().split()) map(int,input().split()) m k = 0 0 k dp = [[float("inf") for i in range(2**n)] for j in range(m+1)] [[float("inf") for i in range(2**n)] for j in range(m+1)] dp n , m = map(int,input().split()) map(int,input().split()) n c = list(map(lambda x:int(x)-1,input().split())) list(map(lambda x:int(x)-1,input().split())) c kagi = [] [] kagi k += 2**j 2**j k b = map(int,input().split()) map(int,input().split()) b
n , m = map(int,input().split())
kagi = []
for i in range(m):
    a , b = map(int,input().split())
    c = list(map(lambda x:int(x)-1,input().split()))
    k = 0
    for j in c:
        k += 2**j
    kagi.append((a,k))
dp = [[float("inf") for i in range(2**n)] for j in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for j in range(2**n):
        dp[i+1][j] = min(dp[i][j],dp[i+1][j])
        dp[i+1][j | kagi[i][1]] = min(dp[i+1][j | kagi[i][1]],dp[i][j] + kagi[i][0])

if dp[-1][-1] != float("inf"):
    print(dp[-1][-1])
else:
    print(-1)