#include <iostream>
#include <fstream>
#include <math.h>

using namespace std;
typedef struct punct
{
  int x,y;
  float dist;
};
punct v[100];
int n,k,boss_x,boss_y;
float distanta(int x,int y,int boss_x,int boss_y);
ifstream fin("date.in");
int main()
{
    cin>>n>>k;
    cin>>boss_x>>boss_y;
    for(int i=1;i<=n;i++)
        {
            fin>>v[i].x>>v[i].y;
            v[i].dist=distanta(v[i].x,v[i].y,boss_x,boss_y);
        }
    for(int i=1;i<n;i++)
      for(int j=i+1;j<=n;j++)
            if(v[i].dist>v[j].dist)
                {
                  punct aux = v[i];
                  v[i]=v[j];
                  v[j]=aux;
                }
             else if(v[i].dist==v[j].dist)
                   {
                    if(v[i].x>v[j].x)
                        {
                          punct aux = v[i];
                          v[i]=v[j];
                          v[j]=aux;
                        }
                    else
                        if(v[i].x==v[j].x)
                            if(v[i].y>v[j].y)
                                {
                                  punct aux = v[i];
                                  v[i]=v[j];
                                  v[j]=aux;
                                }
                   }
    for(int i=1;i<=k;i++) cout<<v[i].x<<" "<<v[i].y<<endl;
    return 0;
}
float distanta(int x,int y,int boss_x,int boss_y)
{
  return sqrt((x-boss_x)*(x-boss_x)+(y-boss_y)*(y-boss_y));
}