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


#define rep(i, n) for(int i = 0; i < (n); i++)




void solve() {
	int n, m; cin >> n >> m;
	int a[1000], c[1000];
	rep(i, m) {
		cin >> a[i];
		int b; cin >> b;
		c[i] = 0;
		rep(j, b) {
			int p; cin >> p;
			c[i] |= (1 << (p - 1));
		}
	}
	int dest = (1 << n) - 1;
	unsigned int q[4096];
	rep(i, 4096) q[i] = 99999999;
	q[0] = 0;
	rep(i, m) {
		rep(j, dest) {
			q[j | c[i]] = min(q[j | c[i]], q[j] + a[i]);
		}
	}
	if (q[dest] == 99999999) cout << -1 << endl;
	else cout << q[dest] << endl;
}

int main() {


	solve();


	return 0;
}