#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    long long n;
    cin >> n;
    long long a[n];
    for(long long i = 1; i <= n; i++) cin >> a[i];
    long long q;
    cin >> q;
    long long b[10000], c[10000];
    for(long long i = 1; i <= q; i++)
    {
        long long br = 0;
        cin >> b[i] >> c[i];
        long long j = b[i];
        long long k = c[i];
        for(j; j < k; j++)
        {
            cout << a[j] << " " << a[j + 1] << endl;
            if(a[j] > a[j + 1]) br++;
        }
        if(br == 0 || br == 1)
        {
            cout << br << endl;
            cout << "DA" << endl;
        }
        else
        {
            cout << br << endl;
            cout << "NE" << endl;
        }
    }
    return 0;
}