#include <bits/stdc++.h>
using namespace std;
int dp[1 << 12];
int main()
{
    int n, m;
    scanf("%d%d",&n,&m);
    for (int i = (1 << n) - 1; ~i; i--) dp[i] = 1e9;
    dp[0] = 0;
    for (int i = 1; i <= m; i++)
    {
        int a,b,k;
        scanf("%d%d",&a,&b);
        int c = 0;
        for (int j = 0; j < b; j++)
        {
            scanf("%d",&k);
            c |= (1 << k-1);
        }
        for (int j = (1 << n) - 1; ~j; j--)
        {
            dp[j | c] = min(dp[j | c], dp[j] + a);//背包
        }
    }
    int ans = dp[(1<<n) - 1];
    if (ans == 1e9) cout << -1;
    else cout << ans;
}
