import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import std.bitmanip;
import std.math;
import std.regex;

class Key {
  public int price;
  public BitArray canOpen;

  this(int price, int[] boxNumbers, int maxBoxSize) {
    this.price = price;
    this.canOpen = BitArray(maxBoxSize.iota.map!(i => boxNumbers.canFind(i+1)).array);
  }
}

void main() {
  int N, M; readf("%d %d\n", &N, &M);
  Key[] keys;
  foreach(z; 0..M) {
    int price, canOpenCount; readf("%d %d\n", &price, &canOpenCount);
    keys ~= new Key(price, readln.split.to!(int[]), N);
  }
  
  uint[BitArray] dp;
  BitArray[] updated = [BitArray(false.repeat(N).array)];
  dp[updated[0]] = 0;

  while(true) {
    BitArray[] nextUpdated;
    foreach(state; updated) {
      foreach(key; keys) {
        auto next = state | key.canOpen;
        if (next == state) continue;
        if (next in dp && dp[next] <= dp[state] + key.price) continue;

        dp[next] = dp[state] + key.price;
        nextUpdated ~= next;
      }
    }
    debug nextUpdated.writeln;
    debug dp.writeln;
    if (nextUpdated.empty) break;
    updated = nextUpdated;
  }

  auto allOpened = BitArray(true.repeat(N).array);
  writeln(allOpened in dp ? dp[allOpened].to!string : "-1");
}