#include <bits/stdc++.h>

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

template <typename T>
void debug2dvec_(const std::vector<std::vector<T>>& v, const std::string& v_name = "v", 
                 const std::size_t max_width = 180, const std::size_t max_height = 50) {
	if(v.size() == 0) { std::cerr << "v.size() is 0." << std::endl; return; }
	if(v.at(0).size() == 0) { std::cerr << "v.at(0).size() is 0." << std::endl; return; }
	if(max_height < 4) { std::cerr << "max_height ( " << max_height << " ) is too small." << std::endl; return; }
	
	const std::size_t max_i = std::min( max_height - 4, v.size() );
	std::vector<std::stringstream> ss(max_i + 4);

	/* 変数名と行番号(i)を表示 */
	std::size_t left_width = v_name.size();
	std::ostringstream oss;
	oss << max_i - 1;
	left_width = max( left_width, oss.str().size() );
	ss.at(0)  << "┏"; for(std::size_t i = 0; i < left_width + 2; ++i) ss.at(0)  << "━"; ss.at(0)  << "┳━";
	ss.at(1)  << "┃ " << std::setw(left_width) << v_name << " ┃ ";
	ss.at(2)  << "┣"; for(std::size_t i = 0; i < left_width + 2; ++i) ss.at(2)  << "━"; ss.at(2)  << "╋━";
	for(std::size_t i = 0; i < max_i; ++i) ss.at(i + 3) << "┃ " << std::setw(left_width) << i << " ┃ ";
	ss.back() << "┗"; for(std::size_t i = 0; i < left_width + 2; ++i) ss.back() << "━"; ss.back() << "┻━";
	
	/* 配列内容をを表示 */
	std::size_t current_width = left_width + 4;
	for(std::size_t j = 0; j < v.at(0).size(); ++j) {
		std::size_t max_element_width = (j < 10) ? 1 : 2;
		for(std::size_t i = 0; i < max_i; ++i) {
			std::ostringstream oss;
			oss << v.at(i).at(j);
			max_element_width = std::max( max_element_width, oss.str().size() );
		}

		if(current_width + max_element_width + 3 > max_width) break;
		current_width += max_element_width + 1;

		for(std::size_t k = 0; k < max_element_width + 1; ++k) ss.at(0)  << "━";
		ss.at(1) << std::setw(max_element_width) << j << " ";
		for(std::size_t k = 0; k < max_element_width + 1; ++k) ss.at(2)  << "━";
		for(std::size_t k = 0; k < max_element_width + 1; ++k) ss.back() << "━";
		for(std::size_t i = 0; i < max_i; ++i) ss.at(i + 3) << std::setw(max_element_width) << v.at(i).at(j) << " ";
	}

	/* 右端を表示 */
	ss.at(0)  << "┓";
	ss.at(1)  << "┃";
	ss.at(2)  << "┫";
	for(std::size_t i = 0; i < max_i; ++i) ss.at(i + 3) << "┃";
	ss.back() << "┛";

	/* 実際に標準エラー出力 */
	for(auto& e : ss) {
		std::cerr << e.str() << std::endl;
	}
}

vector<ll> a;
vector<ll> c;

int main(int argc, const char* argv[]) {
	ll n = 0; // number of boxes ( <= 12   )
	ll m = 0; // number of keys  ( <= 1000 )
	cin >> n >> m;
	a = vector<ll>(m, 0);
	c = vector<ll>(m, 0);
	vector<bool> can_be_opened(n, false);

	rep(i, m) {
		cin >> a.at(i);
		ll b; cin >> b;
		
		rep(j, b) {
			ll tmp_c;
			cin >> tmp_c;
			c.at(i) |= (1 << (tmp_c - 1));
			can_be_opened.at( tmp_c - 1 ) = true;
		}
	}

	rep(i, n) {
		if(can_be_opened.at(i) == false) {
			cout << -1 << endl;
			return 0;
		}
	}

	vector<vector<ll>> dp( m + 1, vector<ll>(1 << n, 1000000000) ); // dp[i][j] = i 番目までの key で状態 j にする 最小費用
	
	rep(j, 1 << n) {
		dp[0][j] = 1000000000; // key が 0 個だと、宝箱は開けられない。LLONG_MAX だとバグる
	}

	rep(i, m + 1) {
		dp[i][0] = 0; // 開ける宝箱がない場合、key が幾つでも価格は 0
	}

	rep(i, m) {
		rep(j, 1 << n) {
			dp[i+1][j] = min( dp[i+1][j], dp[i][j] );
			ll j2 = ( j | c.at(i) );
			dp[i+1][j2] = min({ dp[i+1][j2], dp[i][j]+a[i], dp[i][j2] });
		}
	}

	cout << dp[m][(1 << n) - 1] << endl;

	//debug2dvec_(dp, "dp");

	return 0;
}


Measured memory_bytes: 32384