#include <iostream>
#include <vector>

using namespace std;

int main() {
    const int INF = 1145141919;
    int n, m;
    cin >> n >> m;

    vector<int> dp(1 << n, INF);
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        int can = 0;
        for (int j = 0; j < b; j++) {
            int c;
            cin >> c;
            can |= 1 << (c - 1);
        }

        for (int j = 0; j < 1 << n; j++) {
            dp[j | can] = min(dp[j | can], dp[j] + a);
        }
    }

    cout << (dp[(1 << n) - 1] == INF ? -1 : dp[(1 << n) - 1]) << endl;
    return 0;
}