/*#include <stdio.h>
int rec(int n)
{
if(n%2==1)
{
printf("%d ",n/2);
}
else
{
printf("%d ",3*n+1);
}
}
int main()
{
int a,b;
scanf("%d %d",&a,&b);
for(a==1)
{
printf("%d ", 3*n+1);
}
return 0;
}
//9 -> 20
*/
#include <stdio.h>
struct p
{
int math;
int information;
int count;
};
int main ()
{
struct p st[1001];
struct p temp;
int n,i,j,cnt=0;
scanf ("%d",&n);
for (i=0; i<n; i++)
{
scanf ("%d %d",&st[i].math,&st[i].information);
st[i].count = i+1;
}
for (i=0; i<n; i++)
{
for (j=0; j<n-1; j++)
{
if (st[j].math < st[j+1].math)
{
temp = st[j];
st[j] = st[j+1];
st[j+1] = temp;
}
if(st[i].information < st[j+1].information)
{
temp = st[i];
st[i] = st[i+1];
st[i+1] = temp;
}
}
}
for (i=0; i< n; i++)
{
printf ("%d %d %d\n",st[i].count,st[i].math,st[i].information);
}
return 0;
}