#include<stdio.h>
#include<string.h>
#include<algorithm>

int a[1005];
int b[1005];
int c[1005];
int dp[1 << 12];

int main() {

	int n, m, C;

	scanf("%d%d", &n, &m);

	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a[i], &b[i]);
		for (int j = 0; j < b[i]; j++) {
			scanf("%d", &C);
			C--;
			c[i] |= 1 << C;
		}
	}

	memset(dp, 0x7f, sizeof(dp));

	dp[0] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < (1 << n); j++) {
			if (dp[j] >= 0) {
				dp[j | c[i]] = std::min(dp[j] + a[i], dp[j | c[i]]);
			}
		}
	}

	if (dp[(1 << n) - 1] == 2139062143) printf("-1");
	else printf("%d\n", dp[(1 << n) - 1]);

	return 0;

}
