#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n; vector as(n); for(Int i=0;i>as[i]; vector fs(n,1),gs(n,1); for(Int i=0;i=as[i]) gs[i]=gs[i-1]+1; } Int q; cin>>q; for(Int i=0;i>l>>r; Int len=r-l+1; cout<<(fs[r]>=len)<<" "<<(gs[r]>=len)<<"\n"; } cout<