#include using namespace std; using ll=long long; #define MOD 998244353 #define MAX 2100000 #define INF 1001000000 using Graph=vector>; void update(vector &tree,int x,int a,int b,int i,int left,int right){ if(b<=left||right<=a){ return; } if(a<=left&&right<=b){ tree.at(i)=x; return; } if(tree.at(i)!=-1){ tree.at(2*i+1)=tree.at(i); tree.at(2*i+2)=tree.at(i); tree.at(i)=-1; } update(tree,x,a,b,2*i+1,left,(left+right)/2); update(tree,x,a,b,2*i+2,(left+right)/2,right); } int main(){ int N; cin>>N; vector> a(N); for(int i=0;i>a.at(i).first; a.at(i).second=i; } int n=1; while(n tree(2*n-1,-1); for(int i=0;i