/* sequential tag system to Kantate translator */
/* written by Keymaker */

#include <stdio.h>
int sp,ep,co,datlen=0,seglen,loc,ml=0,pl=0,a,x,y;
char mem[1000],prog[10000];
int main(int argc, char **argv){
  while(1){
    a=getchar();
    if(a=='0'){mem[ml]=0;ml++;}
    else if(a=='1'){mem[ml]=1;ml++;}
    else if(a=='.'){break;}
  }
  if(ml==0){printf("Error, no initial memory described.\n");return 0;}
  while(1){
    a=getchar();
    if(a==';'){prog[pl]=';';pl++;datlen=datlen+3;}
    else if(a=='0'){prog[pl]='0';pl++;datlen=datlen+6;}
    else if(a=='1'){prog[pl]='1';pl++;datlen=datlen+15;}
    else if(a=='.'){break;}
  }
  if(pl==0){printf("Error, no program described.\n");return 0;}
  seglen=datlen+6;co=seglen+3;sp=6;ep=sp+((ml-1)*co);
  printf("\n%% TRANSLATION ");
  for(x=0;x<ml;x++){if(mem[x]==0){printf("z");}else{printf("o");}}printf(" ");
  for(x=0;x<pl;x++){if(prog[x]=='0'){printf("z");}else if(prog[x]=='1'){printf("o");}else{printf("s");}}
  printf("\n%d.-%d. %d.--\n",sp,ep,co);
  printf("%d.--\n",mem[0]*co);
  printf("%d.-%d.",co,co);
  printf(" --%d.\n",co);
  for(x=0;x<pl;x++){
    if(prog[x]==';'){printf("---");}
    else if(prog[x]=='0'){printf("--%d.---",co);}
    else if(prog[x]=='1'){printf("--%d.---%d.-%d.--%d.---",co,co,co,co);}
  }
  printf("\n%d.--\n", mem[1]*co);
  loc=sp+co+3;
  printf("%d.%d.%d.\n",loc,seglen,loc+co);
  printf("9.%d.%d.\n",seglen,loc+co);
  loc=loc+6;
  for(x=0;x<pl;x++){
    if(prog[x]==';'){printf("3.1.0.\n");loc=loc+3;}
    else if(prog[x]=='0'){printf("0.1.%d. 0.1.2.\n",loc+3);loc=loc+6;}
    else if(prog[x]=='1'){printf("0.1.%d. 0.1.2. %d.1.%d. 2.1.%d. 0.1.0.\n",loc+3,loc+3,loc+12,loc+14);loc=loc+15;}
  }
  for(x=2;x<ml;x++){
    printf("%d.--",mem[x]*co);
    if(x!=(ml-1)){for(y=0;y<seglen;y++){printf("-");}}
  }
}
