#include "stdio.h"
 main()
 {  int n,a[5]={0},i=0,t;
  scanf("%d",&n);
   t=n;
  while(t)
   {  a[i++]=t%10;
      t=t/10;
   }         
      printf("%d\n",n);
    for(t=i,i--;i>=0;i--)
   printf("%d ",a[i]);
    printf("\n");
   for(i=0;i<t;i++)
     printf("%d ",a[i]);                                                                                                                                                                                                                                                                                                                                                                                                                                                 t)
     printf("\n");
}