#include using namespace std; using ll = long long; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } vector group_incr(n), group_decr(n); int num = 0; for (int i = 1; i < n; i++) { if (a.at(i - 1) > a.at(i)) num++; group_incr.at(i) = num; } num = 0; for (int i = 1; i < n; i++) { if (a.at(i - 1) < a.at(i)) num++; group_decr.at(i) = num; } int Q; cin >> Q; for (int q = 0; q < Q; q++) { int x, y; cin >> x >> y; int f = group_incr.at(x) == group_incr.at(y); int g = group_decr.at(x) == group_decr.at(y); cout << f << " " << g << endl; } }