// Slower C++ solution:
#include <bits/stdc++.h>

#define rep(i, n) for(int i=0; i<(n); ++i)

#define rep1(i,n) for(int i=1; i<=(n); ++i)

#define repi(i,a,b) for(int i=a; i<=(b); ++i)

#define rrep(i,n) for(int i=(n-1); i>=0; --i)

#define ALL(obj) (obj).begin(), (obj).end()

#define RALL(obj) (obj).rbegin(), (obj).rend()

#define pb push_back

#define mp make_pair

#define to_s to_string

#define sz(v) (int)v.size()

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

#define pr(x) cout<<(x)<<'\n'

#define debug(x) cout << #x << ": " << (x) << '\n'

#define yes "Yes"

#define no "No"

using namespace std;

using ll = long long;

using Edge = pair<int,long long>;

using Graph = vector<vector<Edge>>;

typedef pair<int,int> P;

struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;

int MOD = 1e9 + 7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int dx[4]={1,0,-1,0};

int dy[4]={0,1,0,-1};

 

 

int main(){

    int N,M;

    cin >> N >> M;

    vector<int> A(M),B(M);

    

    rep(i,M){

        int b,tp,idx = 0;

        cin >> A[i] >> b;

        rep(j,b) cin >> tp, idx += int(pow(2,tp-1));

        B[i] = idx;

    }

    

    int DP[M+10][10000];

    rep(i,M+10) rep(j,10000) DP[i][j] = 1e9;

    DP[0][0] = 0;

    

    rep(i,M){

        rep(j,10000) DP[i+1][j | B[i]] = min({DP[i][j | B[i]],DP[i][j]+A[i],DP[i+1][j | B[i]]});

        rep(j,10000) if(DP[i+1][j] == 1e9) DP[i+1][j] = DP[i][j];

    }

    

    

    int ans = DP[M][int(pow(2,N))-1];

    pr(ans == 1e9 ? -1  : ans);

}

// Faster C++ solution for the same problem (measured speedup: 1.4087002930589214x):
#include <bits/stdc++.h>

#define rep(i, n) for (ll i = 0; i < (n); ++i)

#define rep1(i, n) for (ll i = 1; i <= (n); ++i)

#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)

#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))

#define ALL(obj) (obj).begin(), (obj).end()

#define pb push_back

#define to_s to_string

#define len(v) (ll)v.size()

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

#define print(x) cout << (x) << '\n'

#define drop(x) cout << (x) << '\n', exit(0)

#define debug(x) cout << #x << ": " << (x) << '\n'

using namespace std;

using ll = long long;

typedef pair<ll, ll> P;

typedef vector<ll> vec;

typedef vector<vector<ll>> vec2;

typedef vector<vector<vector<ll>>> vec3;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1e9 + 7;

ll devc(ll x, ll y) { return 1 + (x - 1) / y; }



int main()

{

    cin.tie(0);

    ios::sync_with_stdio(0);

    cout << fixed << setprecision(20);



    ll N, M;

    cin >> N >> M;

    vec2 f(M + 1, vec(1 << N, 1e18));

    f[0][0] = 0;



    rep1(i, M){

        ll a, b;

        cin >> a >> b;

        ll state = 0;

        rep(j, b){

            ll c;

            cin >> c;

            --c;

            state += 1 << c;

        }



        rep(j, 1 << N) chmin(f[i][j | state], f[i - 1][j] + a);

        rep(j, 1 << N) chmin(f[i][j], f[i - 1][j]);

    }



    if(f[M][(1 << N) - 1] == 1e18) drop(-1);

    print(f[M][(1 << N) - 1]);



    return 0;

}