import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); String s[]=bu.readLine().split(" "); int n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]); int a[][]=new int[q][3],i; Queue g[]=new LinkedList[n]; for(i=0;i(); for(i=0;i pq=new PriorityQueue<>(new Comparator() { @Override public int compare(int[] o1, int[] o2) { if(o1[1]>o2[1]) return 1; else return -1; }}); int ans[]=new int[n]; for(i=0;i0) ans[i]=ans[i-1]; } for(i=n-2;i>=0;i--) if(ans[i]==0) ans[i]=ans[i+1]; st=new int[4*n]; Arrays.fill(st,Integer.MAX_VALUE); for(i=0;ise) return; if(ss==se) { st[n]=v; return; } int m=(se+ss)/2; if(i<=m) update(ss,m,i,v,2*n+1); else update(m+1,se,i,v,2*n+2); st[n]=Math.min(st[2*n+1],st[2*n+2]); } static int query(int ss,int se,int qs,int qe,int n) { if(ss>se || qese) return Integer.MAX_VALUE; if(qs<=ss && qe>=se) return st[n]; int m=(se+ss)/2; return Math.min(query(ss,m,qs,qe,2*n+1),query(m+1,se,qs,qe,2*n+2)); } }