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

const long INF = 1e18;
int n, m;
int A[1000];
int B[1000];
long DP[1 << 12];
long sub() {
  for (int s = 1; s < (1 << n); ++s) {
    DP[s] = INF;
  }
  
  for (int j = 0; j < m; ++j) {
    for (int s = 0; s < (1 << n); ++s) {
      int t = s | B[j];
      DP[t] = min(DP[t], DP[s] + A[j]);
    }
  }
  
  return DP[(1 << n) - 1];
}

int main() {
  cin >> n >> m;
  for (int j = 0; j < m; ++j) {
    int k;
    cin >> A[j] >> k;
    for (int p = 0; p < k; ++p) {
      int a;
      cin >> a;
      --a;
      B[j] |= 1 << a;
    }
  }
  
  long ans = sub();
  cout << (ans == INF ? -1 : ans) << endl;
}