#include #include #include #define F first #define S second #define MP make_pair using namespace std; bool comp(const pair, int> & a, const pair< pair, int> & b) { if(a.F.F-a.F.S == b.F.F - b.F.S) { if(a.F.S == b.F.S) { return a.S < b.S; } return a.F.S < b.F.S; } return a.F.F - a.F.S > b.F.F - b.F.S; } int main() { while(1) { int n; if(!(cin>>n))break; vector , int> > cities(n); for(int i = 0; i < n; ++i) { cin>>cities[i].F.F>>cities[i].F.S; cities[i].S = i; } sort(cities.begin(), cities.end(), comp); for(int i = 0; i < n; ++i) { if(i < n-1) { cout<