#include <stdio.h>
#include <string.h>

#define MAXLINE 1000

main()
{
  char buf[MAXLINE+1], outbuf[MAXLINE+1];
  char form[MAXLINE+1];
  int len;
  int curpos,nextpos=0;
  int a,b;
  while(fgets(buf,MAXLINE,stdin))
  {
    int n=sscanf(buf,"%d %d",&a,&b);
    if(n==2)
    {
      nextpos=a+b;
      fputs(buf,stdout);
    }
    else
    {
      if(n==1)
      {
        curpos=a;
        sscanf(buf,"%*d %*s %s",form);
      }
      else
      {
        curpos=nextpos;
        sscanf(buf,"%*s %s",form);
      }
 
      if(*form == '*')
        len=0;
      else
      {
        char *f = form;
        for(len=0; *f; ++f) if(*f != '\\') ++len;
      }
      
      char *buf1=buf; while(!isalpha(*buf1)) ++buf1;
      sprintf(outbuf,"%04i %02i %s", curpos, len, buf1);
      fputs(outbuf,stdout);
      nextpos = curpos+len;
    }   
  }
}
