#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,d,k;
cin>>n>>d>>k;
vector<vector<int> >res(n,vector<int>(2,0));
for(int i=0;i<n;i++)
{
cin>>res[i][0]>>res[i][1];
}
sort(res.begin(), res.end(), [](const vector<int> &a, const vector<int> &b)
{
if (a[1] == b[1])
return a[0] < b[0];
return a[1] < b[1];
});
int startp=0;
int temp,currentid,coin;
int endp=res[n-1][1];
while(startp<n)
{
currentid=res[startp][1];
temp=startp;
coin=0;
while(temp<n&&res[temp][1]==currentid&&coin<k)
{
if(res[temp][0]-res[startp][0]<d)
{
coin++;
if(coin>=k)
{
cout<<res[startp][1]<<endl;
while(startp<n&&res[startp][1]==currentid)startp++;
break;
}
}
temp++;
}
while(startp<n&&res[startp][1]==currentid)startp++;
if(startp>=n)break;
}
return 0;
}