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

char s[160];

main(int argc, char *argv[])
{
      int ctr = 0;

      FILE *fp = NULL;

      while(!feof(stdin))
      {
            gets(s);

            if(s[0] == '~' && s[1] == '~' && s[2] == '~')
            {
                  if(fp)
                  {
                        printf(" ");
                        if(!(ctr = (ctr + 1) % 6))
                              printf("&\n");
                        fclose(fp);
                  }
                  printf("+%s", s + 3);
                  strcat(s, ".ASM");
                  fp = fopen(s + 3, "wt");

            } else {
                  if(fp) fprintf(fp, "%s\n", s);
            }
      }

      if(argc > 1) printf(" &");
      printf("\n");
      return 0;
}
