#include typedef long long ll; typedef long double ld; const int INF=1e9,MOD=1e9+7,ohara=1e6+10; const ll LINF=1e18; using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define rrep(i,a,b) for(int i=(a);i<(b);i++) #define rrrep(i,a,b) for(int i=(a);i>=(b);i--) #define all(v) (v).begin(), (v).end() #define Size(n) (n).size() #define Cout(x) cout<<(x)< #define m_p make_pair #define V vector #define U_MAP unordered_map #define pq priority_queue #define rpq priority_queue,greater> #define p_b push_back ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q; ld doua; int dy[]={1,0,-1,0}; int dx[]={0,1,0,-1}; //int dy[]={-1,0,1,-1,1,-1,0,1}; //int dx[]={-1,-1,-1,0,0,1,1,1}; string alph("abcdefghijklmnopqrstuvwxyz"),s; bool fl; struct edge{int to,cost;}; //------ Believe yourself as a genius!!!!!! ------ template class Lazy_Segment_Tree_Range_Minimum_Query { size_t N, M; T ini; vector node, lazy; vector lazyflag; public: Lazy_Segment_Tree_Range_Minimum_Query(const vector& ar, const T ini) : M(ar.size()), ini(ini) { for (N=1; N=0; i--) node[i]=min(node[i*2+1],node[i*2+2]); } Lazy_Segment_Tree_Range_Minimum_Query(const size_t M, const T ini) : M(M), ini(ini) { for (N=1; N1) { lazy[K*2+1]=lazy[K]; lazy[K*2+2]=lazy[K]; lazyflag[K*2+1]=lazyflag[K*2+2]=true; } lazyflag[K]=false; } } void update(int A, int B, T X, int K = 0, int L = 0, int R = -1) { if (R<0) R = N; eval(K,L,R); if (B<=L||R<=A) return; if (A<=L&&R<=B) { lazy[K]=X; lazyflag[K]=true; eval(K,L,R); } else { update(A,B,X,2*K+1,L,(L+R)/2); update(A,B,X,2*K+2,(L+R)/2,R); node[K]=min(node[2*K+1],node[2*K+2]); } } T getvar(int A, int B, int K = 0, int L = 0, int R = -1) { if (R<0) R=N; eval(K,L,R); if (B<=L||R<=A) return ini; if (A<=L&&R<=B) return node[K]; T vl=getvar(A,B,2*K+1,L,(L+R)/2); T vr=getvar(A,B,2*K+2,(L+R)/2,R); return min(vl,vr); } T operator[](size_t idx) { return getvar(idx,idx+1); } T operator[](pair p) { return getvar(p.fi,p.se); } void print() { cout<<"{ "<>n; rep(i,n)cin>>a[i]; Lazy_Segment_Tree_Range_Minimum_Query seg1(n+100,LINF); Lazy_Segment_Tree_Range_Minimum_Query seg2(n+100,LINF); rep(i,n){ seg1.update(i,i+1,0); seg2.update(i,i+1,0); } rep(i,n){ ll le=i,ri=i+1; if(ri==n)break; while(1){ if(a[ri-1]<=a[ri])ri++; if(ri==n)break; else break; } if(le+1==ri)continue; seg1.update(le,ri,1); i=ri-1; } rep(i,n){ ll le=i,ri=i+1; if(ri==n)break; while(1){ if(a[ri-1]>=a[ri])ri++; if(ri==n)break; else break; } if(le+1==ri)continue; seg2.update(le,ri,1); i=ri-1; } cin>>q; rep(i,q){ cin>>b>>c; if(b==c)Cout("1 1"); else{ tmp=seg1.getvar(b,c); tmpp=seg2.getvar(b,c); cout<