#include <bits/stdc++.h>

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	int X = 1 << N;
	vector<long long> dp(X, INT_MAX);
	for (int i = 0; i < M; i++) {
		long long a, b;
		cin >> a >> b;
		int t = 0;
		for (int j = 0; j < b; j++) {
			int c; cin >> c;
			c--;
			t |= 1 << c;
		}
		dp[t] = min(a, dp[t]);
	}
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < X; j++) {
			dp[i | j] = min(dp[i | j], dp[i] + dp[j]);
		}
	}
	if (dp[X-1] == INT_MAX) cout << -1 << endl;
	else  cout << dp[X-1] << endl;
}