#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m;
    cin>>n>>m;
    int a[m],c[m];
    for(int i=0;i<m;i++){
        int b,t;
        cin>>a[i]>>b;
        int id=0;
        for(int j=0;j<b;j++){
            cin>>t;
            id^=(1<<(t-1));
        }
        c[i]=id;
    }
    int dp[1<<n];
    fill(dp,dp+(1<<n),INF);
    dp[0]=0;
    for(int i=0;i<m;i++){
        for(int j=(1<<n)-1;j>=0;j--){
            dp[j|c[i]]=min(dp[j|c[i]],dp[j]+a[i]);
        }
    }
    if(dp[(1<<n)-1]==INF)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
}
