#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

int main(int argc,char* argv[]){
	registerValidation(argc,argv);
	
	int N = 2e5;
	int Q = 2e5;
	int A = 6e6;
	bool L_1 = false;
 
 	switch(atoi(validator.group().c_str())){
        // case 0: MAX_N = 10, MAX_C = 5, MAX_Q = 20; break;
        case 1: N = 3; break;
        case 2: N = Q = 1e3; break;
        case 3: N = 1e3; break;
        case 4: N = Q = 1e5; break;
        case 5: N = 1e5; break;
        case 6: A = 20; break;
        case 7: A = 1e3; break;
        case 8: L_1 = true; break;
        default: break;
    }
    
    int n = inf.readInt(1, N, "n");
    inf.readSpace();
    int q = inf.readInt(1, Q, "q");
    inf.readEoln();
    
    inf.readInts(n, 1, A, "a");
    inf.readEoln();
    
    for (int i = 0; i < q; i++) {
        int l = inf.readInt(1, (L_1 ? 1 : n), "l");
        inf.readSpace();
        int r = inf.readInt(l, n, "r");
        inf.readEoln();
    }
    
    inf.readEof();
    
	return 0;
}
