#include<bits/stdc++.h>
using namespace std;
struct punkt{
char nazwa;
int x, y;
};
int main() {
int n;
cin>>n;
punkt tab[n];
for(int i=0;i<n;i++)
cin>>tab[i].nazwa>>tab[i].x>>tab[i].y;
cout<<"I\n";
for(int i=0;i<n;i++)
if(tab[i].x > 0 && tab[i].y > 0 )
cout<<tab[i].nazwa<<' '<<tab[i].x<<' '<<tab[i].y<<endl;
cout<<"II\n";
for(int i=0;i<n;i++)
if(tab[i].x < 0 && tab[i].y > 0 )
cout<<tab[i].nazwa<<' '<<tab[i].x<<' '<<tab[i].y<<endl;
cout<<"III\n";
for(int i=0;i<n;i++)
if(tab[i].x < 0 && tab[i].y < 0 )
cout<<tab[i].nazwa<<' '<<tab[i].x<<' '<<tab[i].y<<endl;
cout<<"IV\n";
for(int i=0;i<n;i++)
if(tab[i].x > 0 && tab[i].y < 0 )
cout<<tab[i].nazwa<<' '<<tab[i].x<<' '<<tab[i].y<<endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RydWN0IHB1bmt0ewoJY2hhciBuYXp3YTsKCWludCB4LCB5Owp9OwoKaW50IG1haW4oKSB7CgkKCWludCBuOwoJY2luPj5uOwoJcHVua3QgdGFiW25dOwoJZm9yKGludCBpPTA7aTxuO2krKykKCQljaW4+PnRhYltpXS5uYXp3YT4+dGFiW2ldLng+PnRhYltpXS55OwoJY291dDw8IklcbiI7Cglmb3IoaW50IGk9MDtpPG47aSsrKQoJCWlmKHRhYltpXS54ID4gMCAmJiB0YWJbaV0ueSA+IDAgKQoJCQljb3V0PDx0YWJbaV0ubmF6d2E8PCcgJzw8dGFiW2ldLng8PCcgJzw8dGFiW2ldLnk8PGVuZGw7CgkJCWNvdXQ8PCJJSVxuIjsKCWZvcihpbnQgaT0wO2k8bjtpKyspCgkJaWYodGFiW2ldLnggPCAwICYmIHRhYltpXS55ID4gMCApCgkJCWNvdXQ8PHRhYltpXS5uYXp3YT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