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 ushort canOpen;

  this(int price, int[] boxNumbers, int maxBoxSize) {
    this.price = price;
    ushort open = 0;
    bool *bit = cast(bool*)&this.canOpen;
    foreach(i; 1..maxBoxSize+1) if (boxNumbers.canFind(i)) bit[i-1] = true;
  }
}

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[ushort] dp;
  ushort[] updated = [0];
  dp[updated[0]] = 0;

  while(true) {
    ushort[] nextUpdated;
    foreach(state; updated) {
      foreach(key; keys) {
        ushort 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;
  }

  ushort allOpened;
  bool *bits = cast(bool*)&allOpened;
  N.iota.each!(i => bits[i] = true);
  writeln(allOpened in dp ? dp[allOpened].to!string : "-1");
}
