#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int n; long long a[100000]; int f[100000], g[100000]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; REP (i, n) cin >> a[i]; for (int i = 1; i < n; i++) { f[i] = f[i-1]; g[i] = g[i-1]; if (a[i-1] <= a[i]) ++f[i]; if (a[i-1] >= a[i]) ++g[i]; } int q; cin >> q; while (q--) { int l, r; cin >> l >> r; cout << (f[r] - f[l] == r - l ? 1 : 0) << " "; cout << (g[r] - g[l] == r - l ? 1 : 0) << endl; } return 0; }