#include <iostream>
#include <algorithm>
#include <algorithm>
using namespace std;
int a[1001];
int st[1010][20];//st表
int st[1010][20];//st表
void init(int n)//预处理
{
for (int i = 0; i < n; i++)//底层元素设置
st[i][0] = a[i];
{
for (int i = 0; i < n; i++)//底层元素设置
st[i][0] = a[i];
for (int i = 1; (1 << i) <= n; i++)//一层一层往上处理
{
for (int j = 0; j + (1 << i) - 1 < n; j++)
st[j][i] = min(st[j][i - 1],st[j + (1 << (i - 1))][i - 1]);
}
}
{
for (int j = 0; j + (1 << i) - 1 < n; j++)
st[j][i] = min(st[j][i - 1],st[j + (1 << (i - 1))][i - 1]);
}
}
int search(int l, int r)//O(1)查找操作
{
int k = (int)(log((double)(r - l + 1)) / log(2.0));
return min(st[l][k],st[r - (1 << k) + 1][k]);
}
{
int k = (int)(log((double)(r - l + 1)) / log(2.0));
return min(st[l][k],st[r - (1 << k) + 1][k]);
}
int main()
{
int n,m;
cin>>n>>m;
for (int i = 0; i < n; i++)
cin >> a[i];
{
int n,m;
cin>>n>>m;
for (int i = 0; i < n; i++)
cin >> a[i];
init(n);
for(int j=1;j<=m;j++)
{
int l, r;
cin >> l >> r;
cout << search(l,r) << endl;;
}
return 0;
}
cin >> l >> r;
cout << search(l,r) << endl;;
}
return 0;
}