n,m=map(int,input().split())
a=[None]*m
b=[None]*m
c=[None]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
  c[i]=list(map(int,input().split()))
INF=10**18
dp=[INF for _ in  range(1<<n)]
dp[(1<<n)-1]=0
for bit in range((1<<n)-2,-1,-1):
  for u in range(m):
    dumy=bit
    flag=0
    for i in c[u]:
      i-=1
      if not ((bit>>i) & 1):
        dumy|=(1<<i)
        flag=1
    if flag:
      dp[bit]=min(dp[bit],dp[dumy]+a[u])
print([dp[0],-1][dp[0]==INF]) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a=[None]*m a [None]*m [None] None m b=[None]*m b [None]*m [None] None m c=[None]*m c [None]*m [None] None m for i in range(m):
  a[i],b[i]=map(int,input().split())
  c[i]=list(map(int,input().split())) i range(m) range m a[i],b[i]=map(int,input().split()) a[i] a i map(int,input().split()) map int input().split() ().split () input split b[i] b i c[i]=list(map(int,input().split())) c[i] c i list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split INF=10**18 INF 10**18 10 18 INF for _ in  range(1<<n) for _ in  range(1<<n) _ range(1<<n) range 1<<n 1 n for _ in  range(1<<n) INF dp=[INF for _ in  range(1<<n)] dp [INF for _ in  range(1<<n)] dp[(1<<n)-1]=0 dp[(1<<n)-1] dp (1<<n)-1 1<<n 1 n 1 0 for bit in range((1<<n)-2,-1,-1):
  for u in range(m):
    dumy=bit
    flag=0
    for i in c[u]:
      i-=1
      if not ((bit>>i) & 1):
        dumy|=(1<<i)
        flag=1
    if flag:
      dp[bit]=min(dp[bit],dp[dumy]+a[u]) bit range((1<<n)-2,-1,-1) range (1<<n)-2 1<<n 1 n 2 -1 -1 for u in range(m):
    dumy=bit
    flag=0
    for i in c[u]:
      i-=1
      if not ((bit>>i) & 1):
        dumy|=(1<<i)
        flag=1
    if flag:
      dp[bit]=min(dp[bit],dp[dumy]+a[u]) u range(m) range m dumy=bit dumy bit flag=0 flag 0 for i in c[u]:
      i-=1
      if not ((bit>>i) & 1):
        dumy|=(1<<i)
        flag=1
     i c[u] c u i-=1 i 1 if not ((bit>>i) & 1):
        dumy|=(1<<i)
        flag=1
     not ((bit>>i) & 1) (bit>>i) & 1 bit>>i bit i 1 dumy|=(1<<i) dumy 1<<i 1 i flag=1 flag 1 if flag:
      dp[bit]=min(dp[bit],dp[dumy]+a[u]) flag dp[bit]=min(dp[bit],dp[dumy]+a[u]) dp[bit] dp bit min(dp[bit],dp[dumy]+a[u]) min dp[bit] dp bit dp[dumy]+a[u] dp[dumy] dp dumy a[u] a u print([dp[0],-1][dp[0]==INF]) print [dp[0],-1][dp[0]==INF] [dp[0],-1] dp[0] dp 0 -1 dp[0]==INF dp[0] dp 0 INF c=[None]*m [None]*m c a=[None]*m [None]*m a dumy=bit bit dumy flag=0 0 flag b=[None]*m [None]*m b dp=[INF for _ in  range(1<<n)] [INF for _ in  range(1<<n)] dp n,m=map(int,input().split()) map(int,input().split()) n i-=1 1 i flag=1 1 flag dumy|=(1<<i) 1<<i dumy m=map(int,input().split()) map(int,input().split()) m INF=10**18 10**18 INF
n,m=map(int,input().split())
a=[None]*m
b=[None]*m
c=[None]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
  c[i]=list(map(int,input().split()))
INF=10**18
dp=[INF for _ in  range(1<<n)]
dp[(1<<n)-1]=0
for bit in range((1<<n)-2,-1,-1):
  for u in range(m):
    dumy=bit
    flag=0
    for i in c[u]:
      i-=1
      if not ((bit>>i) & 1):
        dumy|=(1<<i)
        flag=1
    if flag:
      dp[bit]=min(dp[bit],dp[dumy]+a[u])
print([dp[0],-1][dp[0]==INF])