#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	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,0X3F3F3F3F);
	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 == 0X3F3F3F3F)
		cout << -1;
	else
		cout << ans;
	return 0;
}