#include <stdio.h> int partition(double* A, double* B, int low, int high) { double pivot = A[low]; int pivotpos = B[low]; while (low < high) { while (low < high && A[high] >= pivot)high--; A[low] = A[high]; B[low] = B[high]; while (low < high && A[low] <= pivot)low++; A[high] = A[low]; B[high] = B[low]; } A[low] = pivot; B[low] = pivotpos; return low; } void quickSort(double* A, double* B, int low, int high) { if (low < high) { int pivotpos = partition(A, B, low, high); quickSort(A, B, low, pivotpos - 1); quickSort(A, B, pivotpos + 1, high); } } int main() { int i,N; scanf("%d",&N); double A[N],B[N]; for(i=0;i<N;i++) { scanf("%lf %lf",&A[i],&B[i]); A[i]+=0.5-0.001*i; B[i]+=0.5-0.001*i; } quickSort(B, A, 0, N-1); for(i=0;i<N;i++) { printf("%.0f %.0f\n",A[i],B[i]); } return 0; }