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

const int INF = 1e9+7;
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<pair<int,int>> key;
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		int s = 0;
		for(int j=0;j<b;j++){
			int c;
			cin >> c;
			c--;
			s |= (1<<c);
		}
		key.emplace_back(s,a);
	}
	vector<int> dp(1<<N,INF);
	dp[0] = 0;
	for(int s=0;s<(1<<N);s++){
		for(int i=0;i<M;i++){
			int t = s | key[i].first;
			int cost = dp[s]+ key[i].second;
			dp[t] = min(dp[t],cost);
		}
	}
	int ans = dp.back();
	if(ans == INF)cout << -1 << endl;
	else cout << ans << endl;
}