#include <stdio.h>
char line[1256];
int i;
int c = -99;
int firsttime = 1;
char head[256];
char buf[1256];

main ()
{
  line[0] = '\0';
  while ((c = gets (buf)) != (char *) NULL)
    {
      if (buf[0] == '!')
	{
	  if (!firsttime)
	    {
	      printf ("%s %s\n", line, head);
	      strcpy (head, buf);
              head[0]='#';
	      strcpy (line, "");
	    }
	  else
	    {
	      firsttime = 0;
	      strcpy (head, buf);
              head[0]='#';
	      line[0] = '\0';
	    }
	}
      else
	{
	  strcat (line, buf);
	}

    }
  printf ("%s %s\n", line, head);
  exit ();
}
