#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int s=(1<<n);
    vector<int> dp(s,1000000009);
    dp[0]=0;
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin>>a>>b;
        int t=0;
        for (int j = 0; j < b; ++j) {
            int c;
            cin>>c;
            --c;
            t+=(1<<c);
        }
        for (int k = 0; k < s; ++k) {
            dp[k|t]=min(dp[k|t],dp[k]+a);
        }
    }
    if(dp[s-1]==1000000009)cout<<"-1"<<endl;
    else cout<<dp[s-1]<<endl;
    return 0;
}