#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(1 << n, INF);
  p.at(0) = 0;
  for (int i = 0; i < m; i++) {
    int a, b, open = 0;
    cin >> a >> b;
    for (int j = 0; j < b; j++) {
      int c;
      cin >> c;
      open += 1 << (c - 1);
    }
    for (int j = 0; j < 1 << n; j++) {
      p.at(j) = min(p.at(j), p.at(j & (~open)) + a);
    }
  }
  if (p.at((1 << n) - 1) == INF) {
    cout << -1 << endl;
  } else {
    cout << p.at((1 << n) - 1) << endl;
  }
}
