// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

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

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

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

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }



using P = pair<int, int>;

typedef long long ll;



const int MOD = 1e9+7;

const int INF = 1e9;

ll dp[1005][10000] = {};

int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N,M;

    cin>>N>>M;

    vector<ll> a(M),b(M);

    vector<vector<ll>> c(M);

    vector<ll> bit(M,0);

    rep(i,M){

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

        c[i].resize(b[i]);

        rep(j,b[i]){

            cin>>c[i][j];

            c[i][j]--;

            bit[i] |= (1<<c[i][j]);

        }

    }

    /*

    rep(i,M){

        print(c[i]);

    }

    */

    print(bit);

    rep(i,M+1)rep(j,10000){

        dp[i][j] = INF;

    }

    dp[0][0] = 0;

    rep(i,M)rep(j,10000){

        dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

        dp[i+1][j|bit[i]] = min(dp[i+1][j|bit[i]], dp[i][j] + a[i]);

    }

    int all1 = 0;

    rep(i,N){

        all1 |= (1<<i);

    }

    cerr<<all1<<endl;

    ll ans = dp[M][all1];

    /*

    rep(i,M+1){

        rep(j,all1+1){

            cerr<<dp[i][j]<<" ";

        }

        cerr<<endl;

    }

    */

    if(ans == INF)ans = -1;

    cout<<ans<<endl;



}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

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

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

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

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

#define dump(x) cerr<<#x<<": "<<x<<endl;

#define bit(k) (1LL<<(k))

#define Yes "Yes"

#define No "No"

#define YES "YES"

#define NO "NO"

typedef long long ll;

template <class T> using vec = vector<T>;

template <class T> using vvec = vector<vec<T>>;

template< typename T1, typename T2 >

ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {

  os << "{" <<p.first << ", " << p.second << "}";

  return os;

}

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

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



const int INF = (ll)1e9;

const ll INFLL = (ll)1e18+1;

const ll MOD = (ll)1e9+7;

const double PI = acos(-1.0);

/*

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

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

const string dir = "DRUL";

*/

ll dp[1010][4100];

int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    cout << fixed << setprecision(20);



    int N, M;

    cin >> N >> M;

    vector<int> a(M), c(M);

    rep(i,M){

        int b;

        cin >> a[i] >> b;

        rep(_, b){

            int d;

            cin >> d;

            c[i] |= bit(d-1);

        }

    }

    rep(i,M+1)rep(j,bit(N))dp[i][j] = INFLL;

    dp[0][0] = 0;

    rep(i,M){

        rep(j, bit(N)){

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

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

        }

    }

    cout <<  ((dp[M][bit(N) - 1] == INFLL) ?  -1: dp[M][bit(N)-1]) << endl;

}

// Fastest known solution for this problem: