#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

using namespace std;

int f[1 << 13];

int main() {

  int n, m; cin >> n >> m;
  memset(f, 0x7f, sizeof(f));
  f[0] = 0;
  int all = 1 << n;
  for (RI i = 1; i <= m; ++i) {
    int cost, cnt; cin >> cost >> cnt;
    int s = 0;
    for (RI j = 1, x; j <= cnt; ++j)
      cin >> x, s |= (1 << (x - 1));
    for (RI j = 0; j < all; ++j)
      f[j | s] = min(f[j | s], f[j] + cost);
  }
  if (f[all - 1] == 0x7f7f7f7f) puts("-1");
  else printf("%d\n", f[all - 1]);
  
  return 0;
}