# include <fstream>
# include <cstdlib>
using namespace std;
ifstream fin("hey.in");
ofstream fout("hey.out");
struct require{
int go,need;
string name;
}man[10010];
int cmp(const void*a,const void *b);
int main(){
int t;
fin>>t;
for(int i=0;i<t;i++)
fin>>man[i].go>>man[i].name>>man[i].need;
qsort(man,t,sizeof(man[0]),cmp);
fout<<man[0].name<<" went out at time "<<man[0].go<<endl;
for(int i=1;i<t;i++) {
if(man[i].go<=(man[i-1].go+man[i-1].need))
fout<<man[i].name<<" went out at time "<<man[i-1].go+man[i-1].need<<endl;
else
fout<<man[i].name<<" went out at time "<<man[i].go<<endl;}
fin.close();
fout.close();
return 0;
}
int cmp(const void*a,const void *b){
struct require *c=(struct require *)a;
struct require *d=(struct require *)b;
if(c->go>d->go) return 1;
else
if(c->go==d->go&&c->name>=d->name)
return 1;
return -1;
}