#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.1415926535897932384626433832795
#define endl "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e12;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct chash {int operator()(int x) const { return x ^ RANDOM; }};
string toString(long long x){stringstream ss;ss << x;string str = ss.str();return str;}
long long fastpow(long long x,long long k){if(!k)return 1;if(k & 1)return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
long long ans = fastpow(x,k/2);ans %= MOD;ans *= ans;ans %= MOD;return ans;}
long long sumF(long long x){int s = 0;while(x)s += x%10,x /= 10;return s;}
bool isS(char c){return (c >= 'a' && c <= 'z');}
bool isB(char c){return (c >= 'A' && c <= 'Z');}
bool isD(char c){return (c >= '0' && c <= '9');}
bool isSqrt(long long x){ long long f = sqrt((long double)x + 0.5); return f*f == x;}
bool isCubic(long long x) {long long f = cbrt((long double)x + 0.5); return f*f*f == x;}
long long lcm(long long a,long long b){return a * (b / __gcd(a,b));}
vector<long long> divVec(long long x){vector<long long> tmp;for(long long i = 1;1LL*i*i <= x;i++){if(x % i == 0){tmp.push_back(i);if(x / i != i)
tmp.push_back(x / i);}sort(tmp.begin(),tmp.end());}return tmp;}
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
int primeFactorsCnt(long long n){int ret = 0;if(n % 2 == 0)ret++;while (n % 2 == 0)n = n/2;for (int i = 3; i*i <= n; i = i + 2){if(n % i == 0)ret++;while (n % i == 0)
n = n/i;}if (n > 2)ret++;return ret;}
int n,m;
struct key
{
    int price,doorsOpenable;
    int mask = 0;
    vector<int> doors;
    key(int price,int doorsOpenable)
    {
        this->price = price;
        this->doorsOpenable = doorsOpenable;
        this->doors.resize(doorsOpenable);
        for(int i = 0;i < doors.size();i++)
        {
            cin >> this->doors[i];
            this->doors[i]--;
            mask |= (1 << this->doors[i]);
        }
    }
};
vector<key> Keys;
int dp[4096][1005];
int solve(int mask,int idx)
{
    if(idx == Keys.size())
        return (mask+1 == (1 << n) ? 0 : 1e9);
    if(dp[mask][idx] != -1)
        return dp[mask][idx];
    int &C = dp[mask][idx] = solve(mask,idx + 1);
    if((mask & Keys[idx].mask) != Keys[idx].mask)
        C = min(C,Keys[idx].price + solve(mask | Keys[idx].mask,idx + 1));
    return C;
}
int32_t main() {
   // freopen("output.txt","w",stdout);
  IO;
    memset(dp,-1,sizeof dp);
    cin >> n >> m;
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        Keys.push_back(key(a,b));
    }
    cout << (solve(0,0) == 1e9 ? -1 : solve(0,0));
}


Measured memory_bytes: 16512