#include<algorithm>
#include<iostream>
#include<string.h>
#include<fstream>
using namespace std;
struct node
{
int Time,need;
string name;
}number[10005];
bool cmp(node a,node b)
{
if(a.Time==b.Time) return a.name<b.name;
else return a.Time<b.Time;
}
int main()
{
ifstream fin("hey.in");
ofstream fout("hey.out");
int n;
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>number[i].Time>>number[i].name>>number[i].need;
}
sort(number+1,number+n+1,cmp);
fout<<number[1].name<<" went out at time "<<number[1].Time<<endl;
for(int i=2;i<=n;i++)
{
if(number[i].Time>(number[i-1].Time+number[i-1].need))
{
fout<<number[i].name<<" went out at time "<<number[i].Time<<endl;
}
else fout<<number[i].name<<" went out at time "<<(number[i-1].Time+number[i-1].need)<<endl;
}
return 0;
}