#include <stdio.h>
#include <stdlib.h>

struct list {
  char buf[1024];
  struct list *next;
} *list_p = NULL;

struct list *list_append(struct list item)
{
  struct list *me = malloc(sizeof(struct list));

  if (!me) return NULL;
  *me = item;
  me->next = list_p;
  return (list_p = me);
}
void list_free(void)
{
#if defined(UNSAFE)
  struct list *p;

  p = list_p;
  while (p) {
    free(p);
    p = p->next;
  }
#else
  struct list *p, *q;

  p = list_p;
  while (p) {
    q = p->next;
    free(p);
    p = q;
  }
#endif
}
void list_print(void)
{
  struct list *p;

  p = list_p;
  while (p) {
    printf("%s", p->buf);
    p = p->next;
  }
}
int main(void)
{
  struct list item;

  while (fgets(item.buf, sizeof(item.buf), stdin)) {
    if (!list_append(item))
      return 1;
  }
  list_print();
  list_free();
  return 0;
}
