#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>>vp;
  for(int i=0;i<M;i++){
    int a,b,c;
    cin>>a>>b;
    int t=0;
    for(int j=0;j<b;j++){
      cin>>c;
      t|=1<<(--c);
    }
    vp.emplace_back(t,a);
  }
  const int n=1<<N;
  const int inf=2e9;
  vector<int>dp(n,inf);
  dp.front()=0;
  for(int u=0;u<n;u++){
    for(auto& p:vp){
      int v=u|p.first;
      dp[v]=min(dp[v],dp[u]+p.second);
    }
  }
  cout<<(dp[n-1]<inf?dp[n-1]:-1)<<endl;
}
