#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,m,a,b,c;
    cin>>n>>m;
    vector<int>dp(1<<n,1000000000);
    dp[0]=0;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        int bit=0;
        for(int j=0;j<b;j++){cin>>c;bit|=1<<(c-1);}
        for(int j=0;j<1<<n;j++)dp[j|bit]=min(dp[j|bit],dp[j]+a);
    }
    cout<<(dp.back()==1000000000?-1:dp.back())<<endl;
    return 0;
}