#include <cstdio>
#include <map>
#include <vector>
using namespace std;
int main(){
map<int, vector<int> > a;
int n, int m;
while (scanf("%d%d", &n, &m) == 2){
for (int i = 0; i < n; i++){
int x;
scanf("%d", &x);
if (!a.count(x)){
a[x] = vector<int>();
}
else
{
a[x].push_back(i + 1);
}
}
while (m--)
{
int k, v;
scanf("%d%d", &k, &v);
printf("%d", a[v][k-1]);
}
}
return 0;
}