// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



//#define int long long

#define ll long long

#define all(v) (v).begin(), (v).end()

#define rep(i,n) for(int i=0;i<n;++i)

#define rep1(i,n) for(int i=1;i<n;++i)

#define FOR(i, m, n) for(int i = m; i < n; i++)

#define EPS (1e-7)

#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef pair<ll, ll> P;

typedef vector<ll> vl;

typedef vector<vector<ll> > vvl;

typedef vector<vector<vector<ll> > > vvvl;

ll MOD = 1000000007;

const long long L_INF = 1LL << 60;

const int INF = 2147483647; // 2^31-1

const double PI = acos(-1);

//cout<<fixed<<setprecision(10);



template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}

template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};

const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};



signed main()

{   

    gearup;

    int n,m; cin >> n >> m;

    vl a(m),b(m),c(m);

    rep(i,m){

        cin >> a[i] >> b[i];

        rep(j,b[i]){

            int d; cin >> d; d--;

            c[i] |= (1<<d);

        }

    }

    vvl dp(m+1,vl(5000,INF));

    dp[0][0] = 0;

    rep(i,m){

        rep(j,(1<<n)){

            chmin(dp[i+1][j],dp[i][j]);

            chmin(dp[i+1][j|c[i]],dp[i][j]+a[i]);

        }

    }

    if(dp[m][(1<<n)-1] != INF)cout << dp[m][(1<<n)-1] << endl;

    else cout << -1 << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.1352223260024892x):
#include <bits/stdc++.h>

using namespace std;



//#define int long long

#define all(v) (v).begin(), (v).end()

#define rall(v) (v).rbegin(), (v).rend()

#define rep(i,n) for(int i=0;i<n;++i)

#define rep1(i,n) for(int i=1;i<n;++i)

#define exrep(i, a, b) for(ll i = a; i < b; i++)

#define out(x) cout << x << endl

#define EPS (1e-7)

#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long double ld;

typedef long long int ll;

typedef unsigned long long int ull;

typedef vector<int> vi;

typedef vector<char> vc;

typedef vector<bool> vb;

typedef vector<double> vd;

typedef vector<string> vs;

typedef vector<pair<int,int> > vpii;

typedef vector<vector<int> > vvi;

typedef vector<vector<char> > vvc;

typedef vector<vector<bool> > vvb;

typedef vector<vector<double> > vvd;

typedef vector<vector<string> > vvs;

typedef vector<ll> vl;

typedef vector<vector<ll> > vvl;

typedef vector<vector<vector<ll> > > vvvl;

ll MOD = 1000000007;

const long long L_INF = 1LL << 60;

const int INF = 2147483647; // 2^31-1

const double PI = acos(-1);

//cout<<fixed<<setprecision(10);



template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}

template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};

const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};



signed main()

{   

  gearup;

  ll n,m; cin >> n >> m;

  vl cost(m),type(m),bit(m);

  rep(i,m){

    cin >> cost[i] >> type[i];

    ll sum = 0;

    rep(j,type[i]){

      ll c; cin >> c;c--;

      sum |= (1<<c);

    }

    bit[i] = sum;

  }



  //dp[i][bit] iの鍵までの最大の部分bit

  vvl dp(m+1,vl(1<<n,L_INF));

  dp[0][0] = 0;

  rep(i,m){

    for(int j=0;j<(1<<n);j++){

      chmin(dp[i+1][j],dp[i][j]); //iの鍵を使わない

      chmin(dp[i+1][j|bit[i]],dp[i][j] + cost[i]);

    }

  }

  ll res = dp[m][(1<<n)-1];

  cout << ((res==L_INF)?-1:res) << endl;

}