#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>


using namespace std;

int main(int argc, char *argv[])
{
     ifstream infile; //declare a file
    infile.open("DATA3.txt", ios::in); //open it
    
    
    ofstream outfile; //declare a outfile
    outfile.open("OUT3.txt", ios::out);//open the outfile
    
    for (int j=1;j<=5;j++)
{
    string game;
   getline (infile, game);
   outfile <<game<<endl;
   
   
   int need=0;
   char array[game.length()+1];
   
   
   for (int i=1; i<=game.length(); i++)
   {  
       array[i-1]=game[i-1];
       //cout <<array[i-1];
       if (game.substr(i-1,1)!=".")
       {
           need=need+1;
       }
  }
  
  
  int counter=1;
  int starting [need+1], velocity[need+1];
    for (int i=1; i<=game.length(); i++)
   {
   if (game[i-1]!='.')
   {starting[counter]=i;
   //cout<<starting[counter];
    velocity[counter]=int(game[i-1])-48;
    //cout <<velocity[counter];
   counter+=1;}
  }
  
  
int temp;
bool flag=false;

while(1)
{
  flag = false;
  for (int i=1; i<=need; i++)
  {
      
     temp=starting[i]+velocity[i]-1;
 // cout <<temp;
    if (temp>=game.length())
     {
      flag=true;
      break;
       }
       else
       {
           
       
      
      array[temp]=char(velocity[i]+48); //char output 
      
      
         // replacing the number with .  
       if(array[starting[i]-1]== char(velocity[i]+48))
       {
        array[starting[i]-1]='.';
       }      
       //else if(i==2 && array[temp]!= '.' && array[temp]!= velocity[i])
//      {
//        array[temp]= char(array[temp]-48)+ char(velocity[i]+48);
//        cout << int(array[temp]-48)+ int(velocity[i])<< endl;  
//        }

     starting[i]=temp+1;
      }
  }
  

    
  
  if (flag==true)
   break;
  else   
   {  
         for (int i=1; i<=game.length(); i++)
   {  
       outfile <<array[i-1];
   }
   outfile <<endl;
   }

   }
  
  
                            
                            
}                      
                            
                           
  


    outfile.close(); //closes the file
   infile.close (); //closes the infile
    
    

    system("PAUSE");
    return EXIT_SUCCESS;
}

