n,m = map(int,input().split())
dp = [2**63]*4096
dp[0] = 0
for i in range(m):
  a,b = map(int,input().split())
  mask = 0
  c = list(map(int,input().split()))
  for i in c:
    mask |= ( 1 << i-1 )
  nxtdp = dp[:]
  for j in range(1 << n):
    if dp[j] < 2 ** 63:
      nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a)
  dp = nxtdp
print(dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m dp = [2**63]*4096 dp [2**63]*4096 [2**63] 2**63 2 63 4096 dp[0] = 0 dp[0] dp 0 0 for i in range(m):
  a,b = map(int,input().split())
  mask = 0
  c = list(map(int,input().split()))
  for i in c:
    mask |= ( 1 << i-1 )
  nxtdp = dp[:]
  for j in range(1 << n):
    if dp[j] < 2 ** 63:
      nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a)
  dp = nxtdp i range(m) range m a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b mask = 0 mask 0 c = list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in c:
    mask |= ( 1 << i-1 )
   i c mask |= ( 1 << i-1 ) mask 1 << i-1 1 i-1 i 1 nxtdp = dp[:] nxtdp dp[:] dp : for j in range(1 << n):
    if dp[j] < 2 ** 63:
      nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a)
   j range(1 << n) range 1 << n 1 n if dp[j] < 2 ** 63:
      nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a)
   dp[j] < 2 ** 63 dp[j] dp j 2 ** 63 2 63 nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a) nxtdp[j | mask] nxtdp j | mask j mask min(nxtdp[j | mask], dp[j] + a) min nxtdp[j | mask] nxtdp j | mask j mask dp[j] + a dp[j] dp j a dp = nxtdp dp nxtdp print(dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1) print dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1 dp[(1<<n)-1] < 2**63 dp[(1<<n)-1] dp (1<<n)-1 1<<n 1 n 1 2**63 2 63 dp[(1<<n)-1] dp (1<<n)-1 1<<n 1 n 1 -1 c = list(map(int,input().split())) list(map(int,input().split())) c n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m dp = [2**63]*4096 [2**63]*4096 dp mask = 0 0 mask mask |= ( 1 << i-1 ) 1 << i-1 mask b = map(int,input().split()) map(int,input().split()) b dp = nxtdp nxtdp dp a,b = map(int,input().split()) map(int,input().split()) a nxtdp = dp[:] dp[:] nxtdp
n,m = map(int,input().split())
dp = [2**63]*4096
dp[0] = 0
for i in range(m):
  a,b = map(int,input().split())
  mask = 0
  c = list(map(int,input().split()))
  for i in c:
    mask |= ( 1 << i-1 )
  nxtdp = dp[:]
  for j in range(1 << n):
    if dp[j] < 2 ** 63:
      nxtdp[j | mask] = min(nxtdp[j | mask], dp[j] + a)
  dp = nxtdp
print(dp[(1<<n)-1] if dp[(1<<n)-1] < 2**63 else -1)
