<pre name="code" class="cpp">#include<iostream> #include<vector> #include<map> using namespace std; map<int, vector<int> >a; int main() { int n,m,i,x,y; while(cin>>n>>m) { a.clear(); for(i=0;i<n;i++) { cin>>x; if(!a.count(x)) { a[x]=vector<int>(); } a[x].push_back(i+1); } while(m--) { cin>>x>>y; if(!a.count(y)||a[y].size()<x) cout<<0<<endl; else cout<<a[y][x-1]<<endl; } } return 0; }