#include <cstdio>
#include <vector>
#include <algorithm>

#define INF 1000000000

using namespace std;

int main() {
    int n, m, a, b, c, t;
    scanf("%d%d", &n, &m);
    vector< pair<int, int> > k(m + 1);
    for (int i = 1; i <= m; ++i) {
        t = 0;
        scanf("%d%d", &a, &b);
        for (int j = 0; j < b; ++j) scanf("%d", &c), t |= (1 << (c - 1));
        k.at(i) = {a, t};
    }
    vector< vector<int> > dp(m + 1, vector<int>(1 << n, INF));
    dp.at(0).at(0) = 0;
    for (int i = 1; i <= m; ++i) {
        dp.at(i) = dp.at(i - 1);
        for (int j = 0; j < (1 << n); ++j) dp.at(i).at(j | k.at(i).second) = min(dp.at(i).at(j | k.at(i).second), dp.at(i - 1).at(j) + k.at(i).first);
    }
    printf("%d\n", dp.back().back() == INF ? -1 : dp.back().back());
    return 0;
}
