#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let (N, M) = (io.read::<usize>(), io.read::<usize>());
    let mut key = vec![0usize; M];
    let mut cost = vec![0usize; M];
    for i in 0..M {
        let (mut a, mut b) = (io.read::<usize>(), io.read::<usize>());
        cost[i] = a;
        let mut treasure = 0usize;
        for _ in 0..b {
            let mut n: usize = io.read();
            n -= 1;
            treasure |= 1 << n;
        }
        key[i] = treasure;
        //io.debug2(&key[i], &cost[i]);
    }
    let INF = std::usize::MAX - 1 << 30;

    let mut dp: Vec<Vec<usize>> = vec![vec![INF; 1 << N]; M];
    for i in 0..M {
        dp[i][0] = 0;
    }
    dp[0][key[0]] = cost[0] as usize;
    for i in 1..M {
        //  io.debug2(i, key[i]);
        for j in 0..(1 << N) {
            //io.debug2(j, j | key[i]);
            //let mn: usize = min(dp[i - 1][j | key[i]], dp[i - 1][j] + cost[i]);
            //io.debug(mn);

            // let miteru: usize = j | key[i];
            // println!(
            //     "dpv : {}, min: {}, miteru: {}",
            //     dp[i][j | key[i]],
            //     mn,
            //     miteru
            // );
            dp[i][j] = min(dp[i - 1][j], dp[i][j]);
            dp[i][j | key[i]] = min(dp[i][j | key[i]], dp[i - 1][j | key[i]]);
            dp[i][j | key[i]] = min(dp[i][j | key[i]], dp[i - 1][j] + cost[i]);
            //dp[i][miteru] = mn;

            // println!(
            //     "i = {}, j = {} , min -> {}, {}",
            //     i,
            //     j,
            //     dp[i - 1][j | key[i]],
            //     dp[i - 1][j] + cost[i]
            // );
            //dp[i][j] = min(dp[i][j], dp[i - 1][j]);

            //dp[i][miteru] = mn;
            //println!("{}", dp[i][miteru]);
        }
        //println!("i={}, dp[i] = {:?}", i, dp[i]);
    }
    if dp[M - 1][(1 << N) - 1] == INF {
        io.writeln(-1);
    } else {
        io.writeln(dp[M - 1][(1 << N) - 1]);
    }
    //io.debug(dp);
}
// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug>(&mut self, val1: S, val2: S) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


Measured memory_bytes: 41212