def main():
  N,M=map(int,input().split())
  A=[0]*M
  import heapq
  import collections
  from itertools import permutations
  table=collections.defaultdict(list)
  AC=[[0,0] for i in range(M)]
  C=[set() for i in range(M)]
  for i in range(M):
    a,b=map(int,input().split())
    AC[i][0]=a
    tmp=set(map(int,input().split()))
    for x in tmp:
      AC[i][1] |= 1<<(x-1)
  dp=[10**9]*(2**N)
  dp[0]=0

  for i in range(1,2**N):
    k=0
    s=set()
    for j in range(1,i):
      if i & j == j:
        dp[i]=min(dp[i],dp[j]+dp[i^j])
    for a,c in AC:
      if c&i == i:
        dp[i]=min(dp[i],a)
    #print(dp[i],bin(i))

  if dp[-1]==10**9:
    print(-1)
  else:
    print(dp[-1])
main() def main():
  N,M=map(int,input().split())
  A=[0]*M
  import heapq
  import collections
  from itertools import permutations
  table=collections.defaultdict(list)
  AC=[[0,0] for i in range(M)]
  C=[set() for i in range(M)]
  for i in range(M):
    a,b=map(int,input().split())
    AC[i][0]=a
    tmp=set(map(int,input().split()))
    for x in tmp:
      AC[i][1] |= 1<<(x-1)
  dp=[10**9]*(2**N)
  dp[0]=0

  for i in range(1,2**N):
    k=0
    s=set()
    for j in range(1,i):
      if i & j == j:
        dp[i]=min(dp[i],dp[j]+dp[i^j])
    for a,c in AC:
      if c&i == i:
        dp[i]=min(dp[i],a)
    #print(dp[i],bin(i))

  if dp[-1]==10**9:
    print(-1)
  else:
    print(dp[-1]) main N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M A=[0]*M A [0]*M [0] 0 M import heapq heapq import collections collections from itertools import permutations table=collections.defaultdict(list) table collections.defaultdict(list) collections.defaultdict collections defaultdict list [0,0] for i in range(M) for i in range(M) i range(M) range M for i in range(M) [0,0] 0 0 AC=[[0,0] for i in range(M)] AC [[0,0] for i in range(M)] set() for i in range(M) for i in range(M) i range(M) range M for i in range(M) set() set C=[set() for i in range(M)] C [set() for i in range(M)] for i in range(M):
    a,b=map(int,input().split())
    AC[i][0]=a
    tmp=set(map(int,input().split()))
    for x in tmp:
      AC[i][1] |= 1<<(x-1)
   i range(M) range M a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b AC[i][0]=a AC[i][0] [i] AC i 0 a tmp=set(map(int,input().split())) tmp set(map(int,input().split())) set map(int,input().split()) map int input().split() ().split () input split for x in tmp:
      AC[i][1] |= 1<<(x-1)
   x tmp AC[i][1] |= 1<<(x-1) AC[i][1] [i] AC i 1 1<<(x-1) 1 x-1 x 1 dp=[10**9]*(2**N) dp [10**9]*(2**N) [10**9] 10**9 10 9 2**N 2 N dp[0]=0 dp[0] dp 0 0 for i in range(1,2**N):
    k=0
    s=set()
    for j in range(1,i):
      if i & j == j:
        dp[i]=min(dp[i],dp[j]+dp[i^j])
    for a,c in AC:
      if c&i == i:
        dp[i]=min(dp[i],a)
    #print(dp[i],bin(i))

   i range(1,2**N) range 1 2**N 2 N k=0 k 0 s=set() s set() set for j in range(1,i):
      if i & j == j:
        dp[i]=min(dp[i],dp[j]+dp[i^j])
     j range(1,i) range 1 i if i & j == j:
        dp[i]=min(dp[i],dp[j]+dp[i^j])
     i & j == j i & j i j j dp[i]=min(dp[i],dp[j]+dp[i^j]) dp[i] dp i min(dp[i],dp[j]+dp[i^j]) min dp[i] dp i dp[j]+dp[i^j] dp[j] dp j dp[i^j] dp i^j i j for a,c in AC:
      if c&i == i:
        dp[i]=min(dp[i],a)
    #print(dp[i],bin(i))

   a c AC if c&i == i:
        dp[i]=min(dp[i],a)
    #print(dp[i],bin(i))

   c&i == i c&i c i i dp[i]=min(dp[i],a) dp[i] dp i min(dp[i],a) min dp[i] dp i a if dp[-1]==10**9:
    print(-1)
  else:
    print(dp[-1]) dp[-1]==10**9 dp[-1] dp -1 10**9 10 9 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 main() main def main():
  N,M=map(int,input().split())
  A=[0]*M
  import heapq
  import collections
  from itertools import permutations
  table=collections.defaultdict(list)
  AC=[[0,0] for i in range(M)]
  C=[set() for i in range(M)]
  for i in range(M):
    a,b=map(int,input().split())
    AC[i][0]=a
    tmp=set(map(int,input().split()))
    for x in tmp:
      AC[i][1] |= 1<<(x-1)
  dp=[10**9]*(2**N)
  dp[0]=0

  for i in range(1,2**N):
    k=0
    s=set()
    for j in range(1,i):
      if i & j == j:
        dp[i]=min(dp[i],dp[j]+dp[i^j])
    for a,c in AC:
      if c&i == i:
        dp[i]=min(dp[i],a)
    #print(dp[i],bin(i))

  if dp[-1]==10**9:
    print(-1)
  else:
    print(dp[-1]) def main():
  N,M=map(int,input().split())
  A=[0]*M
  import heapq
  import collections
  from itertools import permutations
  table=collections.defaultdict(list)
  AC=[[0,0] for i in range(M)]
  C=[set() for i in range(M)]
  for i in range(M):
    a,b=map(int,input().split())
    AC[i][0]=a
    tmp=set(map(int,input().split()))
    for x in tmp:
      AC[i][1] |= 1<<(x-1)
  dp=[10**9]*(2**N)
  dp[0]=0

  for i in range(1,2**N):
    k=0
    s=set()
    for j in range(1,i):
      if i & j == j:
        dp[i]=min(dp[i],dp[j]+dp[i^j])
    for a,c in AC:
      if c&i == i:
        dp[i]=min(dp[i],a)
    #print(dp[i],bin(i))

  if dp[-1]==10**9:
    print(-1)
  else:
    print(dp[-1]) main
def main():
  N,M=map(int,input().split())
  A=[0]*M
  import heapq
  import collections
  from itertools import permutations
  table=collections.defaultdict(list)
  AC=[[0,0] for i in range(M)]
  C=[set() for i in range(M)]
  for i in range(M):
    a,b=map(int,input().split())
    AC[i][0]=a
    tmp=set(map(int,input().split()))
    for x in tmp:
      AC[i][1] |= 1<<(x-1)
  dp=[10**9]*(2**N)
  dp[0]=0

  for i in range(1,2**N):
    k=0
    s=set()
    for j in range(1,i):
      if i & j == j:
        dp[i]=min(dp[i],dp[j]+dp[i^j])
    for a,c in AC:
      if c&i == i:
        dp[i]=min(dp[i],a)
    #print(dp[i],bin(i))

  if dp[-1]==10**9:
    print(-1)
  else:
    print(dp[-1])
main()