#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

struct Vec {int x, y;};
bool operator < (Vec const & a, Vec const & b) {
    auto aUp = a.y > 0 || (a.y == 0 && a.x > 0);
    auto bUp = b.y > 0 || (b.y == 0 && b.x > 0);
    if (aUp != bUp) return aUp > bUp;
    return a.x * 1LL * b.y > b.x * 1LL * a.y;
}

int main () {
    int n;  cin >> n;
    vector <Vec> a (n);
    for (auto & v : a)
        cin >> v.x >> v.y;
    sort (a.begin (), a.end ());
    for (auto v : a)
        cout << v.x << " " << v.y << endl;
    return 0;
}
