#include #include using lint = long long; void solve() { int n; std::cin >> n; std::vector xs(n); for (auto& x : xs) std::cin >> x; std::vector up(n); { int r = 0; for (int l = 0; l < n; ++l) { while (r < n && (r - 1 < l || xs[r - 1] <= xs[r])) ++r; up[l] = r; } } std::vector down(n); { int r = 0; for (int l = 0; l < n; ++l) { while (r < n && (r - 1 < l || xs[r - 1] >= xs[r])) ++r; down[l] = r; } } int q; std::cin >> q; while (q--) { int l, r; std::cin >> l >> r; std::cout << (r < up[l]) << " " << (r < down[l]) << std::endl; } } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }