#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;

int A[1010];
int B[1010];
int C[1010];
int dp[1010][1<<12];

void solve() {
    int N, M; cin >> N >> M;
    REP(i, M) {
        cin >> A[i] >> B[i];
        REP(j, B[i]) {
            int x; cin >> x;
            C[i] |= (1 << (x - 1));
        }
    }

    REP(i, M+1) REP(j, 1 << N) dp[i][j] = 1 << 30;
    dp[0][0] = 0;

    REP(i, M) REP(j, 1 << N) if (dp[i][j] < (1 << 30)) {
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        dp[i+1][j|C[i]] = min(dp[i+1][j|C[i]], dp[i][j] + A[i]);
    }

    cout << (dp[M][(1<<N)-1] == 1<<30 ? -1 : dp[M][(1<<N)-1]) << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
