#include <stdio.h>
#define DIM 10000
char buff[DIM];
int poz=0;
void citeste(int &numar)
{
numar = 0;
while (buff[poz] < '0' || buff[poz] > '9')
if (++poz == DIM)
fread(buff,1,DIM,stdin),poz=0;
while ('0'<=buff[poz] && buff[poz]<='9')
{
numar = numar*10 + buff[poz] - '0';
if (++poz == DIM)
fread(buff,1,DIM,stdin),poz=0;
}
}
int val[250001];
int n,m;
int main()
{
freopen ("cuburi2.in","r",stdin);
freopen ("cuburi2.out","w",stdout);
citeste(n);
citeste(m);
for(int i=1;i<=n;i++) citeste(val[i]);
int p1,p2;
int maxim=0;
long long sum=0;
for(int i=1;i<=m;i++)
{
sum=0;
maxim=0;
int ind=0;
citeste(p1);
citeste(p2);
for(int j=p1;j<=p2;j++)
{
if(maxim<val[j])
{
maxim=val[j];
ind=j;
}
}
printf("%d 0\n",ind);
}
}