#include #include #include using namespace std; typedef long long int ll; int mi[100100]; int ma[100100]; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); for(int i=0;i> a[i]; } int right=0; for(int i=0;i=a[i+1]){ int cp=i; while(cp=a[cp+1]){ cp++; } right=cp; } for(int j=i;j> m; for(int i=0;i> x >> y; if(x==y){ cout << 1 << " " << 1 << endl; } else{ cout << (ma[x]>=y?1:0) << " " << (mi[x]>=y?1:0) << endl; } } }