#include <iostream>
#include <algorithm>
using namespace std;

int d[5009], c[1009], r[1009];
bool vs[19];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int b; cin >> c[i] >> b;
		for (int j = 0; j < b; j++) {
			int t; cin >> t; t--;
			r[i] += (1 << t);
			vs[t] = true;
		}
	}
	for (int i = 0; i < n; i++) {
		if (!vs[i]) {
			cout << -1 << '\n';
			return 0;
		}
	}
	for (int i = 1; i < (1 << n); i++) {
		d[i] = 1000000009;
		for (int j = 0; j < m; j++) 
			d[i] = min(d[i], d[i - (i & r[j])] + c[j]);
	}
	cout << d[(1 << n) - 1] << '\n';
	return 0;
}	