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

#define MAXLINE 1000

int main()
{
  char buf[MAXLINE];
  char outbuf[MAXLINE];
  char form[MAXLINE];
  int len;
  int curpos;
  int nextpos=0;
  int a;
  int b;

  while( fgets(buf, MAXLINE, stdin) )
  {
    int n = sscanf(buf, "%d %d", &a, &b);
    if( 2 == n )
    {
      nextpos = a + b;
      fputs(buf, stdout);
    }
    else
    {
      if( 1 == n )
      {
        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;
    }   
  }
  return 0;
}
