Problem //JSD #include<iostream> #include<set> #include<vector> #define ll long long #include<map> using namespace std; int main(){ int n,m,q,a; ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>m>>q; int Freq[m+1]={0}; for(int i=0;i<n;i++){ cin>>a; Freq[a]++; } int maa=0; for(int i=0;i<=m;i++){ maa=max(maa,Freq[i]); } vector<int > mpq[maa+1]; for(int i=1;i<=m;i++){ mpq[Freq[i]].push_back(i); } vector<int > ans; int count=0; set<int > s; for(ll i=0;i<=maa;i++){ for(auto x: mpq[i]){ s.insert(x); } for(auto x: s){ ans.push_back(x); } } while(q--){ ll p; cin>>p; p-=(n+1); if(p<ans.size()){ cout<<ans[p]; } else{ cout<<(p-ans.size())%m+1; } cout<<"\n"; } return 0; }