#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  vector<int> to(m, 0);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; j++) {
      int c;
      cin >> c, c--;
      to[i] |= 1 << c;
    }
  }
  vector<int> dp(1 << n, INF);
  dp[0] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < (1 << n); j++) {
      int nj = j | to[i];
      dp[nj] = min(dp[nj], dp[j] + a[i]);
    }
  }
  if (dp[(1 << n) - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << dp[(1 << n) - 1] << endl;
  }
}
