#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;

int n, m;
int dp[MAXN];

int main(){
	scanf("%d%d", &n, &m);
	int f = (1 << n) - 1;
	for (int i=1; i<=f; i++)
	    dp[i] = 1e9;
	for (int i=1; i<=m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		int now = 0;
		for (int j=1; j<=b; j++) {
			int c;
			scanf("%d", &c);
			now |= (1 << (c-1));
		}
		for (int i=0; i<=f; i++)
		    if (dp[i] != 1e9) dp[i|now] = min(dp[i|now], dp[i] + a);
	}
	if (dp[f] == 1e9) puts("-1");
	else printf("%d\n", dp[f]);
    return 0;
}
