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

typedef long long ll;

using namespace std;

ll a7=1000000007;

ll inf=100000000000000000;



ll min(ll a,ll b){

    if(a<b)return a;

    return b;

}

ll max(ll a,ll b){

    if(a>b)return a;

    return b;

}

int n;

string memo[10000];

string bina(ll i){

    if(memo[i]!=""){

        return memo[i];

    }

    ll ii=i;

    string ans="";

    while(i>0){

        if(i%2==1){

            ans='1'+ans;

            i=i/2;

        }else{

            ans='0'+ans;

            i=i/2;

        }

    }

    while(ans.size()<n){

        ans='0'+ans;

    }

    memo[ii]=ans;

    return ans;

}



ll bi(string i){

    ll c=1;

    ll ans=0;

    for(ll j=i.size()-1;j>=0;j--){

        if(i[j]=='1'){

            ans=ans+c;

        }

        c=c*2;

    }

    return ans;

}



int main(){

    int m;cin>>n>>m;

    ll aa=pow(2,n);

    ll dp[m+1][aa];

    for(ll i=0;i<=m;i++){

        for(ll j=0;j<aa;j++){

            dp[i][j]=inf;

        }

    }

    dp[0][0]=0;

    string s;

    ll ss;

    ll a[m],b[m];

    ll c[m][n];

    for(ll i=0;i<m;i++){

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

        for(ll j=0;j<b[i];j++){

            cin>>c[i][j];

        }

    }

    

    for(ll i=0;i<m;i++){

        for(ll j=0;j<aa;j++){

            if(dp[i][j]!=inf){

                s=bina(j);

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

                for(ll k=0;k<b[i];k++){

                    s[c[i][k]-1]='1';

                }

                ss=bi(s);

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

            }

        }

    }

    /*for(ll i=0;i<m;i++){

        for(ll j=0;j<aa;j++){

            cout<<dp[i][j]<<' ';

        }

        cout<<endl;

    }*/

    if(dp[m][aa-1]!=inf){

        cout<<dp[m][aa-1]<<endl;

    }else{

        cout<<-1<<endl;

    }

    

    return 0;

}


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

using namespace std;

typedef long long ll;

//#include <boost/multiprecision/cpp_ll.hpp>

//typedef boost::multiprecision::cpp_ll ll;

typedef long double dd;

#define i_7 (ll)(1E9+7)

//#define i_7 998244353

#define i_5 i_7-2

ll mod(ll a){

    ll c=a%i_7;

    if(c>=0)return c;

    return c+i_7;

}

typedef pair<ll,ll> l_l;

ll inf=(ll)1E16;

#define rep(i,l,r) for(ll i=l;i<=r;i++)

#define pb push_back

ll max(ll a,ll b){if(a<b)return b;else return a;}

ll min(ll a,ll b){if(a>b)return b;else return a;}

void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);

void Min(ll &pos,ll val){pos=min(pos,val);}

void Add(ll &pos,ll val){pos=mod(pos+val);}

dd EPS=1E-9;

#define endl "\n"

#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



struct Key{

    ll cost;

    ll c;

};



int main(){fastio

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

    Key key[m+1];

    ll b;

    ll c;

    rep(i,1,m){

        cin>>key[i].cost;

        cin>>b;

        key[i].c=0;

        rep(j,0,b-1){

            cin>>c;

            key[i].c+=(1<<(c-1));

        }

    }

    ll dp[m+1][(1<<n)];

    rep(i,0,m)rep(j,0,(1<<n)-1)dp[i][j]=inf;

    dp[0][0]=0;

    rep(i,1,m){

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

            if(dp[i-1][j]==inf)continue;

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

            dp[i][j|key[i].c]=min(dp[i][j|key[i].c],dp[i-1][j]+key[i].cost);

        }

    }

    if(dp[m][(1<<n)-1]==inf){

        cout<<-1<<endl;

    }else{

        cout<<dp[m][(1<<n)-1]<<endl;

    }

    

    return 0;

}