#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define X first #define Y second #define pb push_back #define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X)) #define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X)) #define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X)) #define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X)) #define repe(X,Y) for ((X) = 0;(X) < (Y);++(X)) #define peat(X,Y) for (;(X) < (Y);++(X)) #define all(X) (X).begin(),(X).end() #define rall(X) (X).rbegin(),(X).rend() #define eb emplace_back #define UNIQUE(X) (X).erase(unique(all(X)),(X).end()) #define Endl endl #define NL <<"\n" using namespace std; using ll=long long; using pii=pair; using pll=pair; template using vv=vector>; template inline bool MX(T &l,const T &r){return l inline bool MN(T &l,const T &r){return l>r?l=r,1:0;} //#undef NUIP #ifdef NUIP #include "../benri.h" #else #define out(args...) #endif #ifdef __cpp_init_captures templatevector table(int n, T v){ return vector(n, v);} template auto table(int n, Args... args){auto val = table(args...); return vector(n, move(val));} #endif const ll MOD=1e9+7; //998244353 vector hoge(vector a){ int n=a.size(); vector re(n); reps(i,1,n) re[i]=(a[i-1]<=a[i])+re[i-1]; return re; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout<>n; vector a(n); rep(i,n) cin>>a[i]; auto inc=hoge(a); for(int &x:a) x=-x; auto dec=hoge(a); int Q; cin>>Q; while(Q--){ int l,r; cin>>l>>r; cout<<(inc[r]-inc[l]==r-l)<<" "<<(dec[r]-dec[l]==r-l)<<"\n"; } return 0; }