/*
TASK:brkclk
LANG:C++
*/
#include<iostream>
using namespace std;
int a[10][4][6],b[10];
 int c[5][4][6];   
 int main()
{
     
      int i,j;
    for(j=1;j<=5;j++)
       for(i=1;i<=4;i++)
    {                 char q,w,e;
                     cin>>q>>w>>e;
                     if(q=='#'||q=='=')c[i][j][1]==1;
                       else
                         if(q=='.')c[i][j][1]==-1;
                     if(w=='#'||w=='=')c[i][j][2]==1;
                       else
                         if(w=='.')c[i][j][2]==-1;
                     if(e=='#'||e=='=')c[i][j][3]==1;
                       else
                         if(e=='.')c[i][j][3]==-1;
                         
                         }               
                         if(c[4][2][1]==0)cout<<"114"<<endl;
                         else
                         cout<<"-1"<<endl;
}
