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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, q;
    while (cin >> n >> q) {
        map<int, vector<int>> mp;
        for (int i = 0; i < n; i++) {
            int x;
            cin >> x;
            mp[x].push_back(i + 1);
        }
        while (q--) {
            int v, k;
            cin >> k >> v;
            if (k > mp[v].size())
                cout << 0 << "\n";
            else
                cout << mp[v][k -  1] << "\n";
        }
    }
}