import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int times = in.nextInt();
        int orderHistory = in.nextInt();
        boolean flag = false;
        TreeSet result = new TreeSet<>();
        for(int i = 0; i < times; i++){
            int no = in.nextInt();
            int begin = in.nextInt();
            int end = in.nextInt();
            if(orderHistory >= begin && orderHistory <= end){
                result.add(no);
                flag = true;
            }
        }
    
        if(result.isEmpty()){
            System.out.print("null");
        }else{
            Iterator it = result.iterator();
            while(it.hasNext()){
                System.out.println(it.next());
            }
        }
    }
}