use std::io::{read_to_string, stdin};

fn main() {
    let temp = read_to_string(stdin()).unwrap();
    let mut iter = temp
        .split_ascii_whitespace()
        .map(|x| x.parse::<usize>().unwrap());

    let n = iter.next().unwrap();

    let mut arr = (0..n)
        .map(|_| {
            (
                iter.next().unwrap(), // idx(no.)
                iter.next().unwrap(), // start
                iter.next().unwrap(), // end
            )
        })
        .collect::<Vec<_>>();

    arr.sort_by_key(|x| x.2);

    let mut selected = vec![];

    for (i, s, e) in arr {
        if selected.len() == 0 {
            selected.push((i, e));
        } else {
            if selected.last().unwrap().1 <= s {
                selected.push((i, e));
            }
        }
    }
    println!("{}", selected.len());
    for (i, _) in selected {
        print!("{} ", i);
    }
    println!();
}
