#include #include #include using namespace std; struct point{ int x; int y; point(){x = 0; y = 0;} point(int _x, int _y){ x = _x; y = _y; } }; point p[10009], b; int N, K, x, y; inline double dist(const point &p1, const point &p2){ return sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y)); } bool compare(const point &p1, const point & p2){ double d1 = dist(b, p1); double d2 = dist(b, p2); if(d1 != d2) return d1 < d2; if(p1.x != p2.x) return p1.x < p2.x; return p1.y < p2.y; } int main(){ scanf("%d %d", &N, &K); scanf("%d %d", &b.x, &b.y); for(int i = 1; i <= N; i++){ scanf("%d %d", &p[i].x, &p[i].y); } sort(p + 1, p + N + 1, compare); for(int i = 1; i <= K; i++){ printf("%d %d\n", p[i].x, p[i].y); } return 0; }