#include <stdio.h>
int main(void)
{
typedef struct _block
{
char color;
int number;
} block;
int i = 0, j = 0, m, cardnum;
block hand[13];
block temp;
// 갯 scan
scanf("%d", &cardnum);
// 기
for ( m = 0 ; m < cardnum ; m++ )
{
fflush(stdin);
scanf("%c %d", &hand[m].color, &hand[m].number);
for ( i = m ; i >= 0 ; i-- )
{
for ( j = 0 ; j < i ; j++ )
{
if ( hand[j].number > hand[j+1].number || ( hand[j].number == hand[j+1].number && hand[j].color == 'w'))
{
temp = hand[j+1];
hand[j+1] = hand[j];
hand[j] = temp;
}
}
}
}
for ( j = 0 ; j < cardnum ; j++ )
{
printf("%c %d\n", hand[j].color, hand[j].number);
}
return 0;
}