#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main() {
  int n,m;
  cin>>n>>m;
  int a[10000];
  for (int i=0; i<1<<n; i++) {
    a[i]=1e9;
  }
  a[0]=0;
  for (int i=0; i<m; i++) {
    int v,b;
    cin>>v>>b;
    int open=0;
    for (int j=0; j<b; j++) {
      int c;
      cin>>c; c--;
      open|=1<<c;
    }
    for (int j=0; j<1<<n; j++) {
      a[j|open]=min(a[j|open],a[j]+v);
    }
  }
  if (a[(1<<n)-1]>1e7) cout<<-1<<endl;
  else cout<<a[(1<<n)-1]<<endl;   
  return 0;
}



