#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp=0;//,n3=0,ii=0;
   for(int i=0;i<n;i++){
        cin>>x[i];
        //if(i>0&&x[i]==3&&x[ii]!=3){
          //  n3=x[ii];
           // x[ii]=3;
           // x[i]=n3;
           // ii++;
           // }
    }
   // for(int i=0;i<n;i++){cout<<x[i]<<" "; }
    //cout<<endl;

   int ch=1;
   for(int i=0;i<n&&ch;i++)
   {
       if(x[i]==3){
      ch=0;
       int ch0=1;
           for(int j=i+1;j<n&&ch0;j++)
           {
               if(x[j]==1)
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
                    ch=1;
                    ch0=0;
               }

           }
       }
   }

   temp=0;
   for(int i=0;i<n;i++){
        if(x[i]==1||x[i]==2||x[i]==4){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }

    }
    else if(x[i]==3){
        ++N_taxis;
    }
   }
    if(temp%4==0){
    temp/=4;
    N_taxis+=temp;
      }
    else if(temp%4!=0){
        temp/=4;
        N_taxis+=temp+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
       //if((n==2&&(x[0]+x[1]==3))||(n==3&&(x[0]+x[1]+x[2]<=4))){
        //cout<<1<<endl;

    //}
    //else{
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3%=4;
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4%=4;
        temp2/=4;
        N_taxis+=temp2+1;
    }
    if(temp3==0&&temp4==0)
     cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+1<<endl;
    //}
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp=0,n3=0,ii=0;
   for(int i=0;i<n;i++){
        cin>>x[i];
        if(i>0&&x[i]==3&&x[ii]!=3){
            n3=x[ii];
            x[ii]=3;
            x[i]=n3;
            ii++;
            }
    }

    int ch=1;
   for(int i=0;i<n&&ch;i++)
   {
       if(x[i]==3){
       ch=0;
       int ch0=1;
           for(int j=i+1;j<n&&ch0;j++)
           {
               if(x[j]==1)
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
                    ch=1;
                    ch0=0;
               }

           }
       }
   }

   temp=0;
   for(int i=0;i<n;i++){
        if(x[i]==1||x[i]==2||x[i]==4){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }

    }
    else if(x[i]==3){
        ++N_taxis;
    }
   }
    if(temp%4==0){
    temp/=4;
    N_taxis+=temp;
      }
    else if(temp%4!=0){
        temp/=4;
        N_taxis+=temp+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp=0;
   for(int i=0;i<n;i++){cin>>x[i]; }
   for(int i=0;i<n;i++)
   {
      // if(x[i]==4){++N_taxis; x[i]=0; }
       //else
       //{
           temp=4-x[i];
           for(int j=i+1;j<n&&x[i]!=0&&x[i]!=4;j++)
           {
               if(temp==x[j])
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
               }
           }
       //}
   }

   temp=0;
   for(int i=0;i<n;i++)
    {
        if(x[i]==3||x[i]==4){
           ++N_taxis;
           x[i]=0;
        }
        else if(x[i]==1||x[i]==2){
            temp+=x[i];
        //if(temp==4){
            //++N_taxis;
           // temp=0;
          //  }
    }
    }
    temp/=4;
    N_taxis+=temp;
    //if(temp!=0)
      //  ++N_taxis;

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp=0;//,n3=0,ii=0;
   for(int i=0;i<n;i++){
        cin>>x[i];

          //  n3=x[ii];
           // x[ii]=3;
           // x[i]=n3;
           // ii++;
           // }
    }
   // for(int i=0;i<n;i++){cout<<x[i]<<" "; }
    //cout<<endl;

   int ch=1;
   for(int i=0;i<n&&ch;i++)
   {
       if(x[i]==3){
      ch=0;
       int ch0=1;
           for(int j=0;j<n&&ch0;j++)
           {
               if(x[j]==1)
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
                    ch=1;
                    ch0=0;
               }

           }
       }
   }

   temp=0;
   for(int i=0;i<n;i++){
        if(x[i]==1||x[i]==2||x[i]==4){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }

    }
    else if(x[i]==3){
        ++N_taxis;
    }
   }
    if(temp%4==0){
    temp/=4;
    N_taxis+=temp;
      }
    else if(temp%4!=0){
        temp/=4;
        N_taxis+=temp+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n],ones=0,threes=0,temp=0,NTaxis=0;

    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==1)
            ones++;
        else if(x[i]==3)
            threes++;
    }

    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
        {
            temp+=x[i];
        }
    }

    if(temp>3&&temp%4==0)
    {
        NTaxis+=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4>2)
    {
        temp+=4;
        NTaxis=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4<2)
    {
        if(threes>0)
        {
            NTaxis=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }

    else if(temp>2&&temp%4==2)
    {
        if(ones==0)
        {
            temp+=4;
            NTaxis+=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes>=2)
        {
            NTaxis=threes+temp/4;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes==1)
        {
            NTaxis=temp/4+2;
            cout<<NTaxis<<endl;
        }
    }
    else if(temp>2)
    {
        if(threes>0)
        {
            NTaxis=threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            cout<<1<<endl;
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3=temp1%4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4=temp2%4;
        temp2/=4;
        N_taxis+=temp2;
    }

   if(temp3==0&&temp4==0)
    cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+2<<endl;
   else if(temp3==0&&temp4==2)
    cout<<N_taxis+1<<endl;
    else if(temp3==3||temp4==2||temp3==1)
    cout<<N_taxis+1<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3=temp1%4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4=temp2%4;
        temp2/=4;
        N_taxis+=temp2;
    }

   if(temp3==0&&temp4==0)
    cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+2<<endl;
   else if(temp3==0&&temp4==2)
    cout<<N_taxis+1<<endl;
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int n;
   cin>>n;
   int x[n],N1=0,N2=0,N3=0,N4=0,N=0,temp=0;

   for(int i=0;i<n;i++)
   {
       cin>>x[i];
       if(x[i]==4)
        N4++;
       else if(x[i]==2)
        N2++;
       else if(x[i]==1)
        N1++;
       else
        N3++;
   }
   N+=N4;
   if(N3>=N1){
    N+=N3;
    N1=0;
   }else{
    N+=N3;
    N1-=N3;
   }
   temp=N1+N2*2;
   if(temp%4==0){
    N+=temp/4;
   }else if(temp%4!=0){
    temp/=4;
    N+=temp+1;
   }
   cout<<N<<endl;

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3=temp1%4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4=temp2%4;
        temp2/=4;
        N_taxis+=temp2;
    }

   if(temp3+temp4==0)
    cout<<N_taxis<<endl;
    if(temp3+temp4>4)
    cout<<N_taxis+2<<endl;
    if(temp3+temp4<=4)
        cout<<N_taxis+1<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp=0;//,n3=0,ii=0;
   for(int i=0;i<n;i++){
        cin>>x[i];
        //if(i>0&&x[i]==3&&x[ii]!=3){
          //  n3=x[ii];
           // x[ii]=3;
           // x[i]=n3;
           // ii++;
           // }
    }
   // for(int i=0;i<n;i++){cout<<x[i]<<" "; }
    //cout<<endl;

   int ch=1;
   for(int i=0;i<n&&ch;i++)
   {
       if(x[i]==3){
      ch=0;
       int ch0=1;
           for(int j=0;j<n&&ch0;j++)
           {
               if(x[j]==1)
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
                    ch=1;
                    ch0=0;
               }

           }
       }
   }

   temp=0;
   for(int i=0;i<n;i++){
        if(x[i]==1||x[i]==2||x[i]==4){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }

    }
    else if(x[i]==3){
        ++N_taxis;
    }
   }
    if(temp%4==0){
    temp/=4;
    N_taxis+=temp;
      }
    else if(temp%4!=0){
        temp/=4;
        N_taxis+=temp+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

//
    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3=temp1%4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4=temp2%4;
        temp2/=4;
        N_taxis+=temp2;
    }

    if(temp3==0&&temp4==0)
     cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+2<<endl;
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,temp,N_taxis=0;
   while( cin>>n){
   int x[n];
   for(int i=0;i<n;i++){cin>>x[i]; }
   for(int i=0;i<n;i++)
   {
       if(x[i]==4){++N_taxis; x[i]=0; }
       else
       {
           temp=4-x[i];
           for(int j=i+1;j<n&&x[i]!=0;j++)
           {
               if(temp==x[j])
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
               }
           }
       }
   }

   temp=0;
   for(int i=0;i<n;i++)
    {
        if(x[i]==3){
           ++N_taxis;
           x[i]=0;
        }
        else if(x[i]==1||x[i]==2){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }
    }
    }
    if(temp!=0)
        ++N_taxis;

   cout<<N_taxis<<endl;
   }
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
          temp=x[i];
          else{
            temp=0;
            break;
            }
    }
       if(temp%4==0&&temp!=0)
    {
        temp/=4;
        N_taxis+=temp;
         cout<<N_taxis<<endl;
    return 0;

    }
    else if(temp%4!=0&&temp!=0)
    {
        temp/=4;
        N_taxis+=temp+1;
         cout<<N_taxis<<endl;
    return 0;

    }

    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp2/=4;
        N_taxis+=temp2+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,temp,N_taxis=0;
   cin>>n;
   int x[n];
   for(int i=0;i<n;i++){cin>>x[i]; }
   for(int i=0;i<n;i++)
   {
       if(x[i]==4){++N_taxis; x[i]=0; }
       else
       {
           temp=4-x[i];
           for(int j=i+1;j<n&&x[i]!=0;j++)
           {
               if(temp==x[j])
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
               }
           }
       }
   }

   temp=0;
   for(int i=0;i<n;i++)
    {
        if(x[i]==3){
           ++N_taxis;
           x[i]=0;
        }
        else if(x[i]==1||x[i]==2){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }
    }
    }
    if(temp!=0)
        ++N_taxis;

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n&&x[i]!=3;i++)
    {
          temp=x[i];
       if(temp%4==0)
    {
        temp/=4;
        N_taxis+=temp;
    }
    else if(temp%4!=0)
    {
        temp/=4;
        N_taxis+=temp+1;
    }
    cout<<N_taxis<<endl;
    return 0;
    }

    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp2/=4;
        N_taxis+=temp2+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int n;
   cin>>n;
   int x[n],N1=0,N2=0,N3=0,N4=0,N=0,temp=0;

   for(int i=0;i<n;i++)
   {
       cin>>x[i];
       if(x[i]==4)
        N4++;
       else if(x[i]==2)
        N2++;
       else if(x[i]==1)
        N1++;
       else
        N3++;
   }
   N+=N4;
   if(N3>=N1){
    N+=N3;
   }else{
    N+=N3;
    N1-=N3;
   }
   temp=N1+N2*2;
   if(temp<=4){
    N++;
   }else if(temp>4&&temp%4==0){
    N+=temp/4;
   }else{
    temp/=4+1;
    N+=temp;
   }
   cout<<N<<endl;

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp1=0,temp2=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    if(n==2){
        if(x[1]+x[2]==3)
            cout<<1<<endl;
    }
    else{
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp2/=4;
        N_taxis+=temp2+1;
    }
    }
   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp1=0,temp2=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp2/=4;
        N_taxis+=temp2+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp=0;
   for(int i=0;i<n;i++){cin>>x[i]; }
   for(int i=0;i<n;i++)
   {
      // if(x[i]==4){++N_taxis; x[i]=0; }
       //else
       //{
           temp=4-x[i];
           for(int j=i+1;j<n&&x[i]!=0&&x[i]!=4;j++)
           {
               if(temp==x[j])
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
               }
           }
       //}
   }

   temp=0;
   for(int i=0;i<n;i++)
    {
        if(x[i]==3||x[i]==4){
           ++N_taxis;
           x[i]=0;
        }
        else if(x[i]==1||x[i]==2){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }
    }
    }
    if(temp!=0)
        ++N_taxis;

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3%=4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4%=4;
        temp2/=4;
        N_taxis+=temp2;
    }

    if(temp3==0&&temp4==0)
     cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+2<<endl;
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }

    if(n==2&&(x[0]+x[1]==3)){
        cout<<1<<endl;

    }
    else{

    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp2/=4;
        N_taxis+=temp2+1;
    }

   cout<<N_taxis<<endl;
    }
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }

    if(n==2&&(x[0]+x[1]==3)||n==3&&(x[0]+x[1]+x[2]+x[3]==4)){
        cout<<1<<endl;

    }
    else{

    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp2/=4;
        N_taxis+=temp2+1;
    }

   cout<<N_taxis<<endl;
    }
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n],ones=0,twos=0,threes=0,temp=0,NTaxis=0;

    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==1)
            ones++;
        else if(x[i]==3)
            threes++;
        else if(x[i]==2)
            twos++;
    }

    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
        {
            temp+=x[i];
        }
    }

    if(temp>3&&temp%4==0)
    {
        NTaxis+=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4>2)
    {
        temp+=4;
        NTaxis=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4<2)
    {
        if(threes>0)
        {
            NTaxis=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }

    else if(temp>2&&temp%4==2)
    {
        if(ones==0)
        {
            temp+=4;
            NTaxis+=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes>=2)
        {
            NTaxis=threes+temp/4;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes==1)
        {
            NTaxis=temp/4+2;
            cout<<NTaxis<<endl;
        }
    }
    else if(temp<=2)
    {
        if(twos==1)
        {
            NTaxis=twos+threes;
            cout<<NTaxis<<endl;
        }
        if(threes>0)
        {
            NTaxis=threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            cout<<1<<endl;
        }
    }

    return 0;
}


#include <stdio.h>

int main()
{
    long long n, s1 = 0, s2 = 0, s3 = 0, s4 = 0, sum_all = 0, sum1;
    scanf("%I64d", &n);
    long long a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%I64d", &a[i]);
        if (a[i] == 1)
            s1++;
        else if (a[i] == 2)
            s2++;
        else if (a[i] == 3)
            s3++;
        else
            s4++;
    }
    if (s3 > s1)
    {
        sum1 = s1;
        sum_all = s4 + sum1 + (s3 - sum1) + (s2 / 2) + (s2 - s2/2);
    }
    else
    {
        sum1 = s3;
        sum_all = s4 + (s2 / 2) + sum1;
    }
    printf("%I64d", sum_all);
    return 0;
}


#include <iostream>

using namespace std;
int main()
{
    int n, m,t = 0, s1 = 0, s2 = 0, s3 = 0, s4 = 0;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>m;
        if (m == 1)
            s1++;
        else if (m == 2)
            s2++;
        else if (m == 3)
            s3++;
        else if (m == 4)
            s4++;
    }
    int temp = s2 * 2;
    if (n == 1)
        t = 1;
    else
    {
        t = t + s4;
        if (s3 >= s1)
        {
            t = t + s3;
            while(temp > 0)
            {
                temp = temp - 4;
                t++;
            }
        }
        else
        {
            t = t + s3;
            s1 = s1 - s3;
            while (temp > 0)
            {
                temp = temp - 4;
                t++;
            }
            if (s1 > 2)
            {
                while (s1 > 0)
                {
                    t++;
                    s1 = s1 - 4;
                }
            }
        }
    }
    cout<<t<<endl;
    return 0;
}


#include <stdio.h>

int main()
{
    int n, t, s = 0;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        s = s + a[i];
    }
    t = s / 4;
    if (s % 4 == 0)
        printf("%d", s % 4);
    else
        printf("%d", t + 1);
    return 0;
}


#include <stdio.h>

int main()
{
    int n, t, s = 0;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        s = s + a[i];
    }
    t = s / 4;
    if (s % 4 == 0)
        printf("%d", t);
    else
        printf("%d", t + 1);
    return 0;
}


#include <stdio.h>

using namespace std;

int main()
{
    int n, s, count[5]= {0};
    scanf("%d", &n);
    while (n--)
    {
        scanf("%d", &s);
        count[s] += 1;
    }
    int total = count[4] + count[3] + count[2] / 2;
    count[1] -= count[3];
    if (count[2] % 2 == 1)
    {
        total += 1;
        count[1] -= 2;
    }
    if (count[1] > 0)
    {
        total += (count[1] + 3) / 4;
    }
    printf("%d\n", total);
    return 0;
}


import java.util.Scanner;

public class Main2 {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for(int i = 0 ; i < t ; i++){
			String[] chesser = new String[8];
			boolean[][] firstK = new boolean[8][8];
			boolean[][] secondK = new boolean[8][8];
			for(int j = 0 ; j < 8 ; j++){
				chesser[j] = sc.nextLine();
			}
			int st1_x = -1;
			int st1_y = -1;
			int st2_x = -1;
			int st2_y = -1;
			int ct = 0;
			for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 8 ; k++){
					if(chesser[j].charAt(k) == 'K'){
						if(ct == 0){
							st1_x = k;
							st1_y = j;
							firstK[j][k] = true;
							ct++;
						}else{
							st2_x = k;
							st2_y = j;
							secondK[j][k] = true;
							break;
						}
					}
				}
			}

			for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 8 ; k++){
					if(chesser[j].charAt(k) == '.' || chesser[j].charAt(k) == 'K'){
						if(Math.abs((st1_x-k)+(st1_y-j)) % 4 == 0 && (st1_x-k) % 2 == 0 && (st1_y-j) % 2 == 0){
							firstK[j][k] = true;
						}
						if(Math.abs((st2_x-k)+(st2_y-j)) % 4 == 0 && (st2_x-k) % 2 == 0 && (st2_y-j) % 2 == 0){
							secondK[j][k] = true;
						}
					}
				}
			}
			boolean meet = false;
			for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 8 ; k++){
					if(firstK[j][k] && secondK[j][k]){
						if(Math.max(Math.abs(st1_x-k),Math.abs(st1_y-j)) / 2 % 2 == Math.max(Math.abs(st2_x-k),Math.abs(st2_y-j)) / 2 % 2)
						meet = true;
						break;
					}
				}
			}
			/*for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 8 ; k++){
					if(firstK[j][k]){
						System.out.print("o");
					}else{
						System.out.print("x");
					}
				}
				System.out.println();
			}*/
			if(meet){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
			if(i != t-1)sc.nextLine();
		}
	}
}


import java.util.Scanner;

public class Main2 {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for(int i = 0 ; i < t ; i++){
			String[] chesser = new String[8];
			boolean[][] firstK = new boolean[8][8];
			boolean[][] secondK = new boolean[8][8];
			for(int j = 0 ; j < 8 ; j++){
				chesser[j] = sc.nextLine();
			}
			int st1_x = -1;
			int st1_y = -1;
			int st2_x = -1;
			int st2_y = -1;
			int ct = 0;
			for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 8 ; k++){
					if(chesser[j].charAt(k) == 'K'){
						if(ct == 0){
							st1_x = k;
							st1_y = j;
							firstK[j][k] = true;
							ct++;
						}else{
							st2_x = k;
							st2_y = j;
							secondK[j][k] = true;
							break;
						}
					}
				}
			}

			for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 8 ; k++){
					if(chesser[j].charAt(k) == '.' || chesser[j].charAt(k) == 'K'){
						if(Math.abs((st1_x-k)+(st1_y-j)) % 4 == 0 && (st1_x-k) % 2 == 0 && (st1_y-j) % 2 == 0){
							firstK[j][k] = true;
						}
						if(Math.abs((st2_x-k)+(st2_y-j)) % 4 == 0 && (st2_x-k) % 2 == 0 && (st2_y-j) % 2 == 0){
							secondK[j][k] = true;
						}
					}
				}
			}
			boolean meet = false;
			for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 8 ; k++){
					if(firstK[j][k] && secondK[j][k]){
						meet = true;
						break;
					}
				}
			}
			/*for(int j = 0 ; j < 8 ; j++){
				for(int k = 0 ; k < 8 ; k++){
					if(firstK[j][k]){
						System.out.print("o");
					}else{
						System.out.print("x");
					}
				}
				System.out.println();
			}*/
			if(meet){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
			sc.nextLine();
		}
	}
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A {
	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out;
	public static void main(String[] args) throws IOException {
		begin();
		solve();
		end();
	}
	private static void end() {
		out.close();
	}
	private static void solve() throws IOException {
		int n = nextInt();
		int []dx = {2,2,-2,-2};
		int []dy = {2,-2,2,-2};

		for (int i = 0; i < n; i++) {
			boolean [][]used = new boolean [8][8];
			char [][]a = new char[8][8];
			for (int j = 0; j < 8; j++) {
				a[j] = next().toCharArray();
			}
			ArrayList<Point> p  = new ArrayList<>();
			for (int j = 0; j < 8; j++) {
				for (int k = 0; k < 8; k++) {
					if (a[j][k] == 'K'){
						p.add(new Point(j,k));
					}
				}
			}
			int x = p.get(0).x;
			int y = p.get(0).y;
			Queue<Point> que = new LinkedList<>();
			que.add(new Point(x,y));
			used[x][y] = true;
			while (!que.isEmpty()){
				Point d = que.poll();
				x = d.x;
				y = d.y;
				for (int j = 0; j < 4; j++) {
					if (x+dx[j] < 8 && x+dx[j] >= 0 && y+dy[j] < 8 && y+dy[j] >= 0){
						if (a[x+dx[j]][y+dy[j]] != '#' && !used[x+dx[j]][y+dy[j]]){
							used[x+dx[j]][y+dy[j]] = true;
							que.add(new Point(x+dx[j],y+dy[j]));
						}
					}
				}
			}
			x = p.get(1).x;
			y = p.get(1).y;
			System.out.println(!used[x][y]?"NO":"YES");
		}
	}
	private static long nextLong() throws  IOException {
		return Long.parseLong(next());
	}
	private static void writeln(Object t) {
		out.println(t);
	}
	private static void write(Object t) {
		out.print(t);
	}
	private static int nextInt() throws  IOException {
		return Integer.parseInt(next());
	}
	private static String next() throws IOException {
		while (!st.hasMoreElements())
			st = new StringTokenizer(in.readLine());

		return st.nextToken();
	}
	private static void begin() {
		out = new PrintWriter(new OutputStreamWriter(System.out));
		st = new StringTokenizer("");
		in = new BufferedReader(new InputStreamReader(System.in));
	}

}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A {
	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out;
	public static void main(String[] args) throws IOException {
		begin();
		solve();
		end();
	}
	private static void end() {
		out.close();
	}
	private static void solve() throws IOException {
		int n = nextInt();
		int []dx = {2,2,-2,-2};
		int []dy = {2,-2,2,-2};

		for (int i = 0; i < n; i++) {
			boolean [][]used = new boolean [8][8];
			char [][]a = new char[8][8];
			for (int j = 0; j < 8; j++) {
				a[j] = next().toCharArray();
			}
			ArrayList<Point> p  = new ArrayList<>();
			for (int j = 0; j < 8; j++) {
				for (int k = 0; k < 8; k++) {
					if (a[j][k] == 'K'){
						p.add(new Point(j,k));
					}
				}
			}
			int [][]d = new int [8][8];
			int x = p.get(0).x;
			int y = p.get(0).y;
			Queue<Point> que = new LinkedList<>();
			que.add(new Point(x,y));
			used[x][y] = true;
			while (!que.isEmpty()){
				Point b = que.poll();
				x = b.x;
				y = b.y;
				for (int j = 0; j < 4; j++) {
					if (x+dx[j] < 8 && x+dx[j] >= 0 && y+dy[j] < 8 && y+dy[j] >= 0){
						if ( !used[x+dx[j]][y+dy[j]]){
							used[x+dx[j]][y+dy[j]] = true;
							que.add(new Point(x+dx[j],y+dy[j]));
							d[x+dx[j]][y+dy[j]] = d[x][y]+1;
						}
					}
				}
			}
			x = p.get(1).x;
			y = p.get(1).y;
			System.out.println(!(d[x][y] != 0 && d[x][y]%2 !=1)?"NO":"YES");
		}
	}
	private static long nextLong() throws  IOException {
		return Long.parseLong(next());
	}
	private static void writeln(Object t) {
		out.println(t);
	}
	private static void write(Object t) {
		out.print(t);
	}
	private static int nextInt() throws  IOException {
		return Integer.parseInt(next());
	}
	private static String next() throws IOException {
		while (!st.hasMoreElements())
			st = new StringTokenizer(in.readLine());

		return st.nextToken();
	}
	private static void begin() {
		out = new PrintWriter(new OutputStreamWriter(System.out));
		st = new StringTokenizer("");
		in = new BufferedReader(new InputStreamReader(System.in));
	}

}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A {
	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out;
	static int []dx = {2,2,-2,-2};
	static int []dy = {2,-2,2,-2};
	static boolean [][]used;
	static char [][]a;
	static int [][]d;
	static int ux =0,uy = 0;
	static boolean f = false;
	public static void main(String[] args) throws IOException {
		begin();
		solve();
		end();
	}
	private static void end() {
		out.close();
	}
	private static void solve() throws IOException {
		int n = nextInt();

		for (int i = 0; i < n; i++) {
			a = new char[8][8];
			d = new int [8][8];
			used = new boolean [8][8];
			for (int j = 0; j < 8; j++) {
				a[j] = next().toCharArray();
			}
			ArrayList<Point> p  = new ArrayList<>();
			for (int j = 0; j < 8; j++) {
				for (int k = 0; k < 8; k++) {
					if (a[j][k] == 'K'){
						p.add(new Point(j,k));
					}
				}
			}
			int x = p.get(0).x;
			ux = p.get(1).x;
			uy = p.get(1).y;
			int y = p.get(0).y;
			f = false;
			dfs(x,y,0);
			System.out.println(!f?"NO":"YES");
		}
	}
	private static void dfs(int x, int y, int d) {
		if (f) return;
		if (ux == x && uy == y && d%2 == 0){
			f = true;
			return;
		}
		for (int i = 0; i < 4; i++) {
			if (x+dx[i] < 8 && x+dx[i] >= 0 && y+dy[i] < 8 && y+dy[i] >= 0 && !used[x+dx[i]][y+dy[i]] && a[x+dx[i]][y+dy[i]] != '#'){
				used[x+dx[i]][y+dy[i]] = true;
				dfs(x+dx[i],y+dy[i],++d);
				used[x+dx[i]][y+dy[i]] = false;
			}
		}
	}
	private static long nextLong() throws  IOException {
		return Long.parseLong(next());
	}
	private static void writeln(Object t) {
		out.println(t);
	}
	private static void write(Object t) {
		out.print(t);
	}
	private static int nextInt() throws  IOException {
		return Integer.parseInt(next());
	}
	private static String next() throws IOException {
		while (!st.hasMoreElements())
			st = new StringTokenizer(in.readLine());

		return st.nextToken();
	}
	private static void begin() {
		out = new PrintWriter(new OutputStreamWriter(System.out));
		st = new StringTokenizer("");
		in = new BufferedReader(new InputStreamReader(System.in));
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class TwoSemiKnights_A {
    static char[][] arr;
    static boolean[][] knightOne;
    static boolean[][] knightTwo;
    static boolean check;

    public static void main(String[] args) throws NumberFormatException, IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        int tc = Integer.parseInt( bf.readLine() );

        for( int i = 1 ; i <= tc ;i++){
            check = false;
            knightOne = new boolean[8][8];
            knightTwo = new boolean[8][8];

            int row1 = -1;
            int col1 = -1;
            int row2 = -1;
            int col2 = -1;

            arr = new char[8][8];
            for( int j = 0 ;j < 8 ;j++){
                String line = bf.readLine();
                for( int k = 0 ;k < 8 ;k++){
                    arr[j][k] = line.charAt(k);
                    if( arr[j][k] == 'K'){
                        if( row1 == -1){
                            row1 = j;
                            col1 = k;
                        }else{
                            row2 = j;
                            col2 = k;
                        }
                    }
                }//end for j.
            }//end for j.

            if( i != tc ){
                String t = bf.readLine();
            }

            move(row1,col1);

            moveTwo(row2,col2);

            if( check == true){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }

        }//end for tc.

    }//end main.

    public static int move( int row ,int col ){

        if( row > 7 || row < 0 || col > 7 || col < 0 ){
            return 0 ;
        }

//      if( arr[row][col] == 'K' ){
//          return;
//      }

        if( knightOne[row][col] == true){
            return 0;
        }

        knightOne[row][col] = true;

        int x = move( row + 2 ,col + 2 );
        int y = move( row + 2 ,col - 2);
        int n = move( row - 2 ,col - 2);
        int m = move( row - 2 ,col + 2);
        return 1;
    }//end method.

    public static int moveTwo( int row ,int col ){

        if( row > 7 || row < 0 || col > 7 || col < 0 ){
            return 0;
        }

        if( knightTwo[row][col] == true){
            return 0;
        }

        if( arr[row][col] == '.' || arr[row][col] == 'K' ){
            knightTwo[row][col] = true;
        }

        if( knightOne[row][col] == true && arr[row][col] != '#' ){
            check = true;
        }

        int x = move( row + 2 ,col + 2 );
        int y = move( row + 2 ,col - 2);
        int n = move( row - 2 ,col - 2);
        int m = move( row - 2 ,col + 2);

        return 1;
    }//end method.

}//end class.


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class TwoSemiKnights_A {
    static char[][] arr;
    static boolean[][] knightOne;
    static boolean[][] knightTwo;
    static boolean check;

    public static void main(String[] args) throws NumberFormatException, IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        int tc = Integer.parseInt( bf.readLine() );

        for( int i = 1 ; i <= tc ;i++){
            check = false;
            knightOne = new boolean[8][8];
            knightTwo = new boolean[8][8];

            int row1 = -1;
            int col1 = -1;
            int row2 = -1;
            int col2 = -1;

            arr = new char[8][8];
            for( int j = 0 ;j < 8 ;j++){
                String line = bf.readLine();
                for( int k = 0 ;k < 8 ;k++){
                    arr[j][k] = line.charAt(k);
                    if( arr[j][k] == 'K'){
                        if( row1 == -1){
                            row1 = j;
                            col1 = k;
                        }else{
                            row2 = j;
                            col2 = k;
                        }
                    }
                }//end for j.
            }//end for j.

            if( i != tc ){
                String t = bf.readLine();
            }

            move(row1,col1);

            moveTwo(row2,col2);

            if( check == true){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }

        }//end for tc.

    }//end main.

    public static int move( int row ,int col ){

        if( row > 7 || row < 0 || col > 7 || col < 0 ){
            return 0 ;
        }

//      if( arr[row][col] == 'K' ){
//          return;
//      }

        if( knightOne[row][col] == true){
            return 0;
        }

        knightOne[row][col] = true;

        int x = move( row + 2 ,col + 2 );
        int y = move( row + 2 ,col - 2);
        int n = move( row - 2 ,col - 2);
        int m = move( row - 2 ,col + 2);
        return 1;
    }//end method.

    public static int moveTwo( int row ,int col ){

        if( row > 7 || row < 0 || col > 7 || col < 0 ){
            return 0;
        }

        if( knightTwo[row][col] == true){
            return 0;
        }

        knightTwo[row][col] = true;

        if( knightOne[row][col] == true && arr[row][col] != '#' ){
            check = true;
        }

        int x = move( row + 2 ,col + 2 );
        int y = move( row + 2 ,col - 2);
        int n = move( row - 2 ,col - 2);
        int m = move( row - 2 ,col + 2);

        return 1;
    }//end method.

}//end class.


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class TwoSemiKnights_A {
    static char[][] arr;
    static boolean[][] knightOne;
    static boolean[][] knightTwo;
    static boolean check;

    public static void main(String[] args) throws NumberFormatException, IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        int tc = Integer.parseInt( bf.readLine() );

        for( int i = 1 ; i <= tc ;i++){
            check = false;
            knightOne = new boolean[8][8];
            knightTwo = new boolean[8][8];

            int row1 = -1;
            int col1 = -1;
            int row2 = -1;
            int col2 = -1;

            arr = new char[8][8];
            for( int j = 0 ;j < 8 ;j++){
                String line = bf.readLine();
                for( int k = 0 ;k < 8 ;k++){
                    arr[j][k] = line.charAt(k);
                    if( arr[j][k] == 'K'){
                        if( row1 == -1){
                            row1 = j;
                            col1 = k;
                        }else{
                            row2 = j;
                            col2 = k;
                        }
                    }
                }//end for j.
            }//end for j.

            if( i != tc ){
                String t = bf.readLine();
            }

            newMove( row1 ,col1 ,row2 ,col2 );
            if( check == true){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }

        }//end for tc.

    }//end main.

    static int[] dRow = { 2 , -2 , 2 , -2 };
    static int[] dCol = { 2 , -2 , -2 , 2 };

    public static int newMove( int row1 ,int col1 ,int row2 ,int col2){

        if( row1 > 7 || row1 < 0 || col1 > 7 || col1 < 0 || row2 > 7 || row2 < 0 || col2 > 7 || col2 < 0){
            return 0 ;
        }

        if( row1 == row2 && col1 == col2 && arr[row1][col1] != '#' ){
            check = true;
            return 1;
        }

        if( knightOne[row1][col1] && knightTwo[row2][col2] ){
            return 0;
        }

        knightOne[row1][col1] = true;
        knightTwo[row2][col2] = true;

        for( int i = 0 ;i < 4 ;i++){
            int rowA = row1 + dRow[i];
            int colA = col1 + dCol[i];

            for( int j = 0 ;j < 4 ;j++){
                int rowB = row2 + dRow[j];
                int colB = col2 + dCol[j];

                newMove( rowA,colA,rowB,colB );

            }//end for j.

        }//end for i .

        return 1;
    }//end method new move;

    public static int move( int row ,int col ){

        if( row > 7 || row < 0 || col > 7 || col < 0 ){
            return 0 ;
        }

//      if( arr[row][col] == 'K' ){
//          return;
//      }

        if( knightOne[row][col] == true){
            return 0;
        }

        knightOne[row][col] = true;

        int x = move( row + 2 ,col + 2 );
        int y = move( row + 2 ,col - 2);
        int n = move( row - 2 ,col - 2);
        int m = move( row - 2 ,col + 2);
        return 1;
    }//end method.

    public static int moveTwo( int row ,int col ){

        if( row > 7 || row < 0 || col > 7 || col < 0 ){
            return 0;
        }

        if( knightTwo[row][col] == true){
            return 0;
        }

        knightTwo[row][col] = true;

        if( knightOne[row][col] == true && arr[row][col] != '#' ){
            check = true;
        }

        int x = move( row + 2 ,col + 2 );
        int y = move( row + 2 ,col - 2);
        int n = move( row - 2 ,col - 2);
        int m = move( row - 2 ,col + 2);

        return 1;
    }//end method.

}//end class.


import static java.lang.Math.*;

import java.io.*;
import java.util.*;

public class Template {
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String next() {
		while (st==null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(in.readLine());
			} catch (Exception e) {}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	int[][] a;
	int cur=0;
	boolean was[][][][];
	int[] dx = {2, 2, -2, -2};
	int[] dy = {-2, 2, -2, 2};

	void dfs(int x, int y, int parity) {
		//System.err.println(cur + " " +x + " " + y + " " + parity);
		if (was[cur][parity][x][y]) return;
		was[cur][parity][x][y] = true;

		for (int i=0; i<4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx >= 0 && nx < 8 && ny >= 0 && ny < 8) dfs(nx, ny, 1 - parity);
		}
	}

	public void run() throws Exception {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Long start = System.currentTimeMillis();
			int T = nextInt();

			for (int q=0; q<T; q++) {

				a = new int[8][8];
				was = new boolean[2][2][8][8];

				for (int i=0; i<8; i++) {
					String s = next();
					//System.err.println(s);
					for (int j=0; j<8; j++) if (s.charAt(j) == '#') a[i][j] = -1; else
					if (s.charAt(j) == 'K') a[i][j] = 1;
				}
				cur=0;

				for (int i=0; i<8; i++) {
					for (int j=0; j<8; j++) {
						if (a[i][j] == 1) {
							dfs(i, j, 0);
							cur++;
						}
					}
				}

				boolean ok = false;
				for (int i=0; i<8; i++) {
					for (int j=0; j<8; j++)
						for (int parity = 0 ; parity<2; parity++)
							if (was[0][parity][i][j] && was[1][parity][i][j]) ok = true;
				}

				if (ok) out.println("YES"); else out.println("NO");
			}

		Long end = System.currentTimeMillis();
		//System.out.println((end - start) / 1000.0);
		out.close();
	}

	public static void main(String[] args) throws Exception {
		new Template().run();
	}
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A_212 {
    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
                System.out)));
        int n = nextInt();
        char[][] c = new char[9][9];
        boolean t = false;
        int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
        for (int l = 0; l < n; l++) {
            for (int j = 1; j <= 8; j++) {
                String s = next();
                for (int k = 1; k <= 8; k++) {
                    c[j][k] = s.charAt(k - 1);
                    if (c[j][k] == 'K') {
                        if (!t) {
                            x1 = j;
                            y1 = k;
                        } else {
                            x2 = j;
                            y2 = k;
                        }
                        t = true;
                    }
                }
            }
            // for (int i = 1; i <= 8; i++) {
            // for (int j = 1; j <= 8; j++) {
            // System.out.print(c[i][j]);
            // }
            // System.out.println();
            // }
            // System.out.println(x1 + " " + y1);
            // System.out.println(x2 + " " + y2);
            Queue<Point> que1 = new LinkedList<Point>();
            Queue<Point> que2 = new LinkedList<Point>();
            que1.add(new Point(x1, y1));
            que2.add(new Point(x2, y2));
            boolean used1[][] = new boolean[9][9];
            boolean used2[][] = new boolean[9][9];
            used1[x1][y1] = true;
            used2[x2][y2] = true;
            int inf = (int) 1e5;
            int d1[][] = new int[9][9];
            int d2[][] = new int[9][9];
            for (int i = 1; i <= 8; i++) {
                Arrays.fill(d1[i], inf);
                Arrays.fill(d2[i], inf);
            }
            d1[x1][y1] = 0;
            d2[x2][y2] = 0;
            int dx[] = { -2, -2, 2, 2 };
            int dy[] = { -2, 2, -2, 2 };
            while (!que1.isEmpty()) {
                Point p = que1.poll();
                for (int i = 0; i < 4; i++) {
                    if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
                            && p.y + dy[i] > 0
                            && c[p.x + dx[i]][p.y + dy[i]] != '#'
                            && !used1[p.x + dx[i]][p.y + dy[i]]) {
                        que1.add(new Point(p.x + dx[i], p.y + dy[i]));
                        used1[p.x + dx[i]][p.y + dy[i]] = true;
                        d1[p.x + dx[i]][p.y + dy[i]] = d1[p.x][p.y] + 1;
                    }
                }
            }
            while (!que2.isEmpty()) {
                Point p = que2.poll();
                for (int i = 0; i < 4; i++) {
                    if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
                            && p.y + dy[i] > 0
                            && c[p.x + dx[i]][p.y + dy[i]] != '#'
                            && !used2[p.x + dx[i]][p.y + dy[i]]) {
                        que2.add(new Point(p.x + dx[i], p.y + dy[i]));
                        used2[p.x + dx[i]][p.y + dy[i]] = true;
                        d2[p.x + dx[i]][p.y + dy[i]] = d2[p.x][p.y] + 1;
                    }
                }
            }
            int min = inf;
            boolean t1 = false;
            one: for (int i = 1; i <= 8; i++) {
                for (int j = 1; j <= 8; j++) {
                    if (d1[i][j] == d2[i][j] && d1[i][j] != inf) {
                        if ((d1[i][j] % 2 == 0 && d2[i][j] % 2 == 0)
                                || (d1[i][j] % 2 != 0 && d2[i][j] % 2 != 0)) {
                            System.out.println("YES");
                            t1 = true;
                            break one;
                        }
                    }
                }
            }
            System.out.println((!t1) ? "NO" : "");
        }
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.StringTokenizer;

public class A_212 {
    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
                System.out)));
        int n = nextInt();
        char[][] c = new char[9][9];
        boolean t = false;
        int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
        for (int l = 0; l < n; l++) {
            for (int j = 1; j <= 8; j++) {
                String s = next();
                for (int k = 1; k <= 8; k++) {
                    c[j][k] = s.charAt(k - 1);
                    if (c[j][k] == 'K') {
                        if (!t) {
                            x1 = j;
                            y1 = k;
                        } else {
                            x2 = j;
                            y2 = k;
                        }
                        t = true;
                    }
                }
            }
            // System.out.println(x1 + " " + y1);
            // System.out.println(x2 + " " + y2);
            Queue<Point> que1 = new LinkedList<Point>();
            Queue<Point> que2 = new LinkedList<Point>();
            que1.add(new Point(x1, y1));
            que2.add(new Point(x2, y2));
            boolean used1[][] = new boolean[9][9];
            boolean used2[][] = new boolean[9][9];
            used1[x1][y1] = true;
            used2[x2][y2] = true;
            int inf = (int) 1e5;
            int d1[][] = new int[9][9];
            int d2[][] = new int[9][9];
            for (int i = 1; i <= 8; i++) {
                Arrays.fill(d1[i], inf);
                Arrays.fill(d2[i], inf);
            }
            d1[x1][y1] = 0;
            d2[x2][y2] = 0;
            int dx[] = { -2, -2, 2, 2 };
            int dy[] = { -2, 2, 2, 2 };
            while (!que1.isEmpty()) {
                Point p = que1.poll();
                for (int i = 0; i < 4; i++) {
                    if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
                            && p.y + dy[i] > 0
                            && c[p.x + dx[i]][p.y + dy[i]] != '#'
                            && !used1[p.x + dx[i]][p.y + dy[i]]) {
                        que1.add(new Point(p.x + dx[i], p.y + dy[i]));
                        used1[p.x + dx[i]][p.y + dy[i]] = true;
                        d1[p.x + dx[i]][p.y + dy[i]] = d1[p.x][p.y] + 1;
                    }
                }
            }
            while (!que2.isEmpty()) {
                Point p = que2.poll();
                for (int i = 0; i < 4; i++) {
                    if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
                            && p.y + dy[i] > 0
                            && c[p.x + dx[i]][p.y + dy[i]] != '#'
                            && !used2[p.x + dx[i]][p.y + dy[i]]) {
                        que2.add(new Point(p.x + dx[i], p.y + dy[i]));
                        used2[p.x + dx[i]][p.y + dy[i]] = true;
                        d2[p.x + dx[i]][p.y + dy[i]] = d2[p.x][p.y] + 1;
                    }
                }
            }
            int min = inf;
            for (int i = 1; i <= 8; i++) {
                for (int j = 1; j <= 8; j++) {
                    if (d1[i][j] == d2[i][j]) {
                        min = Math.min(min, d1[i][j]);
                    }
                }
            }
            System.out.println((min == inf) ? "NO" : "YES");

        }
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A_212 {
    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
                System.out)));
        int n = nextInt();
        char[][] c = new char[9][9];
        boolean t = false;
        int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
        for (int l = 0; l < n; l++) {
            for (int j = 1; j <= 8; j++) {
                String s = next();
                for (int k = 1; k <= 8; k++) {
                    c[j][k] = s.charAt(k - 1);
                    if (c[j][k] == 'K') {
                        if (!t) {
                            x1 = j;
                            y1 = k;
                        } else {
                            x2 = j;
                            y2 = k;
                        }
                        t = true;
                    }
                }
            }
            // for (int i = 1; i <= 8; i++) {
            // for (int j = 1; j <= 8; j++) {
            // System.out.print(c[i][j]);
            // }
            // System.out.println();
            // }
            // System.out.println(x1 + " " + y1);
            // System.out.println(x2 + " " + y2);
            Queue<Point> que1 = new LinkedList<Point>();
            Queue<Point> que2 = new LinkedList<Point>();
            que1.add(new Point(x1, y1));
            que2.add(new Point(x2, y2));
            boolean used1[][] = new boolean[9][9];
            boolean used2[][] = new boolean[9][9];
            used1[x1][y1] = true;
            used2[x2][y2] = true;
            int inf = (int) 1e5;
            int d1[][] = new int[9][9];
            int d2[][] = new int[9][9];
            for (int i = 1; i <= 8; i++) {
                Arrays.fill(d1[i], inf);
                Arrays.fill(d2[i], inf);
            }
            d1[x1][y1] = 0;
            d2[x2][y2] = 0;
            int dx[] = { -2, -2, 2, 2 };
            int dy[] = { -2, 2, -2, 2 };
            while (!que1.isEmpty()) {
                Point p = que1.poll();
                for (int i = 0; i < 4; i++) {
                    if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
                            && p.y + dy[i] > 0
                            && c[p.x + dx[i]][p.y + dy[i]] != '#'
                            && !used1[p.x + dx[i]][p.y + dy[i]]) {
                        que1.add(new Point(p.x + dx[i], p.y + dy[i]));
                        used1[p.x + dx[i]][p.y + dy[i]] = true;
                        d1[p.x + dx[i]][p.y + dy[i]] = d1[p.x][p.y] + 1;
                    }
                }
            }
            while (!que2.isEmpty()) {
                Point p = que2.poll();
                for (int i = 0; i < 4; i++) {
                    if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
                            && p.y + dy[i] > 0
                            && c[p.x + dx[i]][p.y + dy[i]] != '#'
                            && !used2[p.x + dx[i]][p.y + dy[i]]) {
                        que2.add(new Point(p.x + dx[i], p.y + dy[i]));
                        used2[p.x + dx[i]][p.y + dy[i]] = true;
                        d2[p.x + dx[i]][p.y + dy[i]] = d2[p.x][p.y] + 1;
                    }
                }
            }
            int min = inf;
            boolean t1 = false;
            one: for (int i = 1; i <= 8; i++) {
                for (int j = 1; j <= 8; j++) {
                    if (d1[i][j] == d2[i][j] && d1[i][j] != inf) {
                        if ((d1[i][j] % 2 == 0 && d2[i][j] % 2 == 0)
                                || (d1[i][j] % 2 != 0 && d2[i][j] % 2 != 0))
                            System.out.println("YES");
                        t1 = true;
                        break one;
                    }
                }
            }
            System.out.println((!t1) ? "NO" : "");
        }
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A_212 {
	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				System.out)));
		int n = nextInt();
		char[][] c = new char[9][9];
		boolean t = false;
		int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
		for (int l = 0; l < n; l++) {
			for (int j = 1; j <= 8; j++) {
				String s = next();
				for (int k = 1; k <= 8; k++) {
					c[j][k] = s.charAt(k - 1);
					if (c[j][k] == 'K') {
						if (!t) {
							x1 = j;
							y1 = k;
						} else {
							x2 = j;
							y2 = k;
						}
						t = true;
					}
				}
			}
			// for (int i = 1; i <= 8; i++) {
			// for (int j = 1; j <= 8; j++) {
			// System.out.print(c[i][j]);
			// }
			// System.out.println();
			// }
			// System.out.println(x1 + " " + y1);
			// System.out.println(x2 + " " + y2);
			Queue<Point> que1 = new LinkedList<Point>();
			Queue<Point> que2 = new LinkedList<Point>();
			que1.add(new Point(x1, y1));
			que2.add(new Point(x2, y2));
			boolean used1[][] = new boolean[9][9];
			boolean used2[][] = new boolean[9][9];
			used1[x1][y1] = true;
			used2[x2][y2] = true;
			int inf = (int) 1e5;
			int d1[][] = new int[9][9];
			int d2[][] = new int[9][9];
			for (int i = 1; i <= 8; i++) {
				Arrays.fill(d1[i], inf);
				Arrays.fill(d2[i], inf);
			}
			d1[x1][y1] = 0;
			d2[x2][y2] = 0;
			int dx[] = { -2, -2, 2, 2 };
			int dy[] = { -2, 2, -2, 2 };
			while (!que1.isEmpty()) {
				Point p = que1.poll();
				for (int i = 0; i < 4; i++) {
					if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
							&& p.y + dy[i] > 0
							&& c[p.x + dx[i]][p.y + dy[i]] != '#'
							&& !used1[p.x + dx[i]][p.y + dy[i]]) {
						que1.add(new Point(p.x + dx[i], p.y + dy[i]));
						used1[p.x + dx[i]][p.y + dy[i]] = true;
						d1[p.x + dx[i]][p.y + dy[i]] = d1[p.x][p.y] + 1;
					}
				}
			}
			while (!que2.isEmpty()) {
				Point p = que2.poll();
				for (int i = 0; i < 4; i++) {
					if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
							&& p.y + dy[i] > 0
							&& c[p.x + dx[i]][p.y + dy[i]] != '#'
							&& !used2[p.x + dx[i]][p.y + dy[i]]) {
						que2.add(new Point(p.x + dx[i], p.y + dy[i]));
						used2[p.x + dx[i]][p.y + dy[i]] = true;
						d2[p.x + dx[i]][p.y + dy[i]] = d2[p.x][p.y] + 1;
					}
				}
			}
			int min = inf;
			boolean t1 = false;
			one: for (int i = 1; i <= 8; i++) {
				for (int j = 1; j <= 8; j++) {
					if (d1[i][j] == d2[i][j] && d1[i][j] != inf) {
						System.out.println("YES");
						t1 = true;
						break one;
					}
				}
			}
			System.out.println((!t1) ? "NO" : "");
		}
	}

	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	private static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A_212 {
	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				System.out)));
		int n = nextInt();
		char[][] c = new char[9][9];
		boolean t = false;
		int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
		for (int l = 0; l < n; l++) {
			for (int j = 1; j <= 8; j++) {
				String s = next();
				for (int k = 1; k <= 8; k++) {
					c[j][k] = s.charAt(k - 1);
					if (c[j][k] == 'K') {
						if (!t) {
							x1 = j;
							y1 = k;
						} else {
							x2 = j;
							y2 = k;
						}
						t = true;
					}
				}
			}
			// for (int i = 1; i <= 8; i++) {
			// for (int j = 1; j <= 8; j++) {
			// System.out.print(c[i][j]);
			// }
			// System.out.println();
			// }
			// System.out.println(x1 + " " + y1);
			// System.out.println(x2 + " " + y2);
			Queue<Point> que1 = new LinkedList<Point>();
			Queue<Point> que2 = new LinkedList<Point>();
			que1.add(new Point(x1, y1));
			que2.add(new Point(x2, y2));
			boolean used1[][] = new boolean[9][9];
			boolean used2[][] = new boolean[9][9];
			used1[x1][y1] = true;
			used2[x2][y2] = true;
			int inf = (int) 1e5;
			int d1[][] = new int[9][9];
			int d2[][] = new int[9][9];
			for (int i = 1; i <= 8; i++) {
				Arrays.fill(d1[i], inf);
				Arrays.fill(d2[i], inf);
			}
			d1[x1][y1] = 0;
			d2[x2][y2] = 0;
			int dx[] = { -2, -2, 2, 2 };
			int dy[] = { -2, 2, -2, 2 };
			while (!que1.isEmpty()) {
				Point p = que1.poll();
				for (int i = 0; i < 4; i++) {
					if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
							&& p.y + dy[i] > 0
						//	&& c[p.x + dx[i]][p.y + dy[i]] != '#'
							&& !used1[p.x + dx[i]][p.y + dy[i]]) {
						que1.add(new Point(p.x + dx[i], p.y + dy[i]));
						used1[p.x + dx[i]][p.y + dy[i]] = true;
						d1[p.x + dx[i]][p.y + dy[i]] = d1[p.x][p.y] + 1;
					}
				}
			}
			while (!que2.isEmpty()) {
				Point p = que2.poll();
				for (int i = 0; i < 4; i++) {
					if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
							&& p.y + dy[i] > 0
						//	&& c[p.x + dx[i]][p.y + dy[i]] != '#'
							&& !used2[p.x + dx[i]][p.y + dy[i]]) {
						que2.add(new Point(p.x + dx[i], p.y + dy[i]));
						used2[p.x + dx[i]][p.y + dy[i]] = true;
						d2[p.x + dx[i]][p.y + dy[i]] = d2[p.x][p.y] + 1;
					}
				}
			}
			int min = inf;
			boolean t1 = false;
			one: for (int i = 1; i <= 8; i++) {
				for (int j = 1; j <= 8; j++) {
					if (d1[i][j] != inf && d2[i][j] != inf) {
						if ((d1[i][j] % 2 == d2[i][j] % 2) && c[i][j] != '#') {
							System.out.println("YES");
							t1 = true;
							break one;
						}
					}
				}
			}
			System.out.println((!t1) ? "NO" : "");
		}
	}

	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	private static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A_212 {
    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
                System.out)));
        int n = nextInt();
        char[][] c = new char[9][9];
        int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
        for (int l = 0; l < n; l++) {
            boolean t = false;
            for (int j = 1; j <= 8; j++) {
                String s = next();
                for (int k = 1; k <= 8; k++) {
                    c[j][k] = s.charAt(k - 1);
                    if (c[j][k] == 'K') {
                        if (!t) {
                            x1 = j;
                            y1 = k;
                        } else {
                            x2 = j;
                            y2 = k;
                        }
                        t = true;
                    }
                }
            }
            Queue<Point> que1 = new LinkedList<Point>();
            Queue<Point> que2 = new LinkedList<Point>();
            que1.add(new Point(x1, y1));
            que2.add(new Point(x2, y2));
            boolean used1[][] = new boolean[9][9];
            boolean used2[][] = new boolean[9][9];
            used1[x1][y1] = true;
            used2[x2][y2] = true;
            int inf = (int) 1e9;
            int d1[][] = new int[9][9];
            int d2[][] = new int[9][9];
            for (int i = 1; i <= 8; i++) {
                Arrays.fill(d1[i], inf);
                Arrays.fill(d2[i], inf);
            }
            d1[x1][y1] = 0;
            d2[x2][y2] = 0;
            int dx[] = { -2, -2, 2, 2 };
            int dy[] = { -2, 2, -2, 2 };
            while (!que1.isEmpty()) {
                Point p = que1.poll();
                for (int i = 0; i < 4; i++) {
                    if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
                            && p.y + dy[i] > 0
                            && !used1[p.x + dx[i]][p.y + dy[i]]) {
                        que1.add(new Point(p.x + dx[i], p.y + dy[i]));
                        used1[p.x + dx[i]][p.y + dy[i]] = true;
                        d1[p.x + dx[i]][p.y + dy[i]] = d1[p.x][p.y] + 1;
                    }
                }
            }
            while (!que2.isEmpty()) {
                Point p = que2.poll();
                for (int i = 0; i < 4; i++) {
                    if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
                            && p.y + dy[i] > 0
                            && !used2[p.x + dx[i]][p.y + dy[i]]) {
                        que2.add(new Point(p.x + dx[i], p.y + dy[i]));
                        used2[p.x + dx[i]][p.y + dy[i]] = true;
                        d2[p.x + dx[i]][p.y + dy[i]] = d2[p.x][p.y] + 1;
                    }
                }
            }
            boolean t1 = false;
            for (int i = 1; i <= 8; i++) {
                for (int j = 1; j <= 8; j++) {
                    if ((d1[i][j] % 2 == d2[i][j] % 2) && c[i][j] != '#'
                            && d1[i][j] != inf && d2[i][j] != inf) {
                        System.out.println("YES");
                        t1 = true;
                        break;
                    }
                }

                if (t1)
                    break;
            }
            if (!t1)
                System.out.println("NO");
        }
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class A_212 {
	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				System.out)));
		int n = nextInt();
		char[][] c = new char[9][9];
		boolean t = false;
		int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
		for (int l = 0; l < n; l++) {
			for (int j = 1; j <= 8; j++) {
				String s = next();
				for (int k = 1; k <= 8; k++) {
					c[j][k] = s.charAt(k - 1);
					if (c[j][k] == 'K') {
						if (!t) {
							x1 = j;
							y1 = k;
						} else {
							x2 = j;
							y2 = k;
						}
						t = true;
					}
				}
			}
			// for (int i = 1; i <= 8; i++) {
			// for (int j = 1; j <= 8; j++) {
			// System.out.print(c[i][j]);
			// }
			// System.out.println();
			// }
			// System.out.println(x1 + " " + y1);
			// System.out.println(x2 + " " + y2);
			Queue<Point> que1 = new LinkedList<Point>();
			Queue<Point> que2 = new LinkedList<Point>();
			que1.add(new Point(x1, y1));
			que2.add(new Point(x2, y2));
			boolean used1[][] = new boolean[9][9];
			boolean used2[][] = new boolean[9][9];
			used1[x1][y1] = true;
			used2[x2][y2] = true;
			int inf = (int) 1e5;
			int d1[][] = new int[9][9];
			int d2[][] = new int[9][9];
			for (int i = 1; i <= 8; i++) {
				Arrays.fill(d1[i], inf);
				Arrays.fill(d2[i], inf);
			}
			d1[x1][y1] = 0;
			d2[x2][y2] = 0;
			int dx[] = { -2, -2, 2, 2 };
			int dy[] = { -2, 2, -2, 2 };
			while (!que1.isEmpty()) {
				Point p = que1.poll();
				for (int i = 0; i < 4; i++) {
					if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
							&& p.y + dy[i] > 0
							&& c[p.x + dx[i]][p.y + dy[i]] != '#'
							&& !used1[p.x + dx[i]][p.y + dy[i]]) {
						que1.add(new Point(p.x + dx[i], p.y + dy[i]));
						used1[p.x + dx[i]][p.y + dy[i]] = true;
						d1[p.x + dx[i]][p.y + dy[i]] = d1[p.x][p.y] + 1;
					}
				}
			}
			while (!que2.isEmpty()) {
				Point p = que2.poll();
				for (int i = 0; i < 4; i++) {
					if (p.x + dx[i] <= 8 && p.x + dx[i] > 0 && p.y + dy[i] <= 8
							&& p.y + dy[i] > 0
							&& c[p.x + dx[i]][p.y + dy[i]] != '#'
							&& !used2[p.x + dx[i]][p.y + dy[i]]) {
						que2.add(new Point(p.x + dx[i], p.y + dy[i]));
						used2[p.x + dx[i]][p.y + dy[i]] = true;
						d2[p.x + dx[i]][p.y + dy[i]] = d2[p.x][p.y] + 1;
					}
				}
			}
			int min = inf;
			for (int i = 1; i <= 8; i++) {
				for (int j = 1; j <= 8; j++) {
					if (d1[i][j] != inf && d2[i][j] != inf) {
						min = Math.min(min, d1[i][j]);
					}
				}
			}
			System.out.println((min == inf) ? "NO" : "YES");
		}
	}

	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	private static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}


import java.util.*;
import java.io.*;
public class q26{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int i=0,j=0,n=0,k=0,a=0,b=0,c=0,d=0,r=0,p=0,q=0,s=0,t=0,test2=0;
		int temp = 0,next=0,prev=0;
		//System.out.println("jdvj");
		String pp="";
		n=scan.nextInt();
		pp = scan.nextLine();
		int[] arr = new int[16];
		//k=scan.nextInt();
		char input1[][] = new char[8][8];
		for(i=0;i<n;i++)
		{	for(j=0;j<8;j++)
			{	pp  = scan.nextLine();
				for(k=0;k<8;k++)
				{//	System.out.println(pp);
				//System.out.println(scan.nextLine());
					input1[j][k] = pp.charAt(k);
					if(input1[j][k] == '.')
					{
						if(arr[j%4+4*(k%4)] == 0)
						{	arr[j%4+4*(k%4)]  = 1;
						}
					}
					if(input1[j][k] == 'K')
					{
						if(p!=-1)
							q=p;
						p=j%4+4*(k%4);
					}
				}
			}
//			System.out.println(p);
//			System.out.println(q);
//			System.out.println(arr[p]);

			if(p==q)
			{	System.out.println("YES");
			}
			else
				System.out.println("NO");
			if(i<n-1)
			{	pp=scan.nextLine();
			}
			for(s=0;s<16;s++)
			{	arr[s] =0;
			}
			p=-1;
			q=-1;

		}

	}

}


import java.util.*;
import java.io.*;
public class q26{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int i=0,j=0,n=0,k=0,a=0,b=0,c=0,d=0,r=0,p=0,q=0,s=0,t=0,test2=0;
		int temp = 0,next=0,prev=0;
		//System.out.println("jdvj");
		String pp="";
		n=scan.nextInt();
		pp = scan.nextLine();
		int[] arr = new int[16];
		//k=scan.nextInt();
		char input1[][] = new char[8][8];
		for(i=0;i<n;i++)
		{	for(j=0;j<8;j++)
			{	pp  = scan.nextLine();
				for(k=0;k<8;k++)
				{//	System.out.println(pp);
				//System.out.println(scan.nextLine());
					input1[j][k] = pp.charAt(k);
					if(input1[j][k] == '.')
					{
						if(arr[j%4+4*(k%4)] == 0)
						{	arr[j%4+4*(k%4)]  = 1;
						}
					}
					if(input1[j][k] == 'K')
					{
						if(p!=-1)
							q=p;
						p=j%4+4*(k%4);
					}
				}
			}
//			System.out.println(p);
//			System.out.println(q);
//			System.out.println(arr[p]);

			if(p==q)
			{	if(arr[p]==1)
					System.out.println("YES");
				else
					System.out.println("NO");

			}
			else
				System.out.println("NO");
			if(i<n-1)
			{	pp=scan.nextLine();
			}
			for(s=0;s<16;s++)
			{	arr[s] =0;
			}
			p=-1;
			q=0;

		}

	}

}


import java.awt.Point;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class div_212 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int o = 1; o <= n; o++) {
			String s[][] = new String[9][9];
			int ind[][] = new int[100][100], k = 0;
			boolean used1[][] = new boolean[9][9], used2[][] = new boolean[9][9];
			for (int j1 = 1; j1 <= 8; j1++) {
				String as = sc.next();
				for (int j2 = 0; j2 < 8; j2++) {
					s[j1][j2 + 1] = as.charAt(j2) + "";
					if (s[j1][j2 + 1].equals("K")) {
						ind[1][++k] = j1;
						ind[1][++k] = j2 + 1;
					}
				}
			}
			int dx[] = { 2, 2, -2, -2, };
			int dy[] = { -2, 2, 2, -2, };
			int d1[][] = new int[9][9], d2[][] = new int[9][9];
			used1[ind[1][1]][ind[1][2]] = true;
			used2[ind[1][3]][ind[1][4]] = true;
			int inf = (int) 1e9;
			for (int i = 1; i <= 8; i++) {
				Arrays.fill(d1[i], inf);
				Arrays.fill(d2[i], inf);
			}
			d1[ind[1][1]][ind[1][2]] = 0;
			d2[ind[1][3]][ind[1][4]] = 0;
			Queue<Point> que1 = new LinkedList<Point>();
			que1.add(new Point(ind[1][1], ind[1][2]));
			Queue<Point> que2 = new LinkedList<Point>();
			que2.add(new Point(ind[1][3], ind[1][4]));
			while (!que1.isEmpty()) {
				Point p = que1.poll();
				for (int i = 0; i < 4; i++) {
					if (p.x + dx[i] > 0 && p.x + dx[i] <= 8 && p.y + dy[i] > 0
							&& p.y + dy[i] <= 8
							&& !used1[p.x + dx[i]][p.y + dy[i]]) {
						used1[p.x + dx[i]][p.y + dy[i]] = true;
						d1[p.x + dx[i]][p.y + dy[i]] = d1[p.x][p.y] + 1;
						que1.add(new Point(p.x + dx[i], p.y + dy[i]));
					}
				}
			}
			while (!que2.isEmpty()) {
				Point p = que2.poll();
				for (int i = 0; i < 4; i++) {
					if (p.x + dx[i] > 0 && p.x + dx[i] <= 8 && p.y + dy[i] > 0
							&& p.y + dy[i] <= 8
							&& !used2[p.x + dx[i]][p.y + dy[i]]) {
						used2[p.x + dx[i]][p.y + dy[i]] = true;
						d2[p.x + dx[i]][p.y + dy[i]] = d2[p.x][p.y] + 1;
						que2.add(new Point(p.x + dx[i], p.y + dy[i]));
					}
				}
			}
			boolean w = false;
			for (int i = 1; i <= 8; i++) {
				for (int j = 1; j <= 8; j++) {
					if (d1[i][j] % 2 == d2[i][j] % 2 && !s[i][j].equals("#")
							&& d1[i][j] != inf && d2[i][j] != inf) {
						w = true;
					}
				}
			}
			if (!w)
				System.out.println("NO");
			else
				System.out.println("YES");
		}
	}
}


import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.*;
public class SemiKnight
{
    static final int INF = Integer.MAX_VALUE;
    static final int NINF = Integer.MIN_VALUE;

    public static void main(String[]args)throws IOException
    {
        Input in = new Input();
        int t = in.nextInt();
        char [][] board = new char[8][8];
        while(t-- > 0)
        {
            for(int i = 0; i < 8; i++)
                board[i] = in.nextLine().toCharArray();

            int r1 = 0;
            int c1 = 0;
            int r2 = 0;
            int c2 = 0;
            boolean first = false;
      outer:for(int r = 0; r < 8; r++)
            {
                for(int c = 0; c < 8; c++)
                {
                    if(board[r][c] == 'K')
                    {
                        if(!first)
                        {
                            r1 = r;
                            c1 = c;
                            first = true;
                        }else
                        {
                            r2 = r;
                            c2 = c;
                            break outer;
                        }
                    }
                }
            }
            boolean ok = false;
            for(int i = 0; i < 8; i++)
            {
                for(int j = 0; j < 8; j++)
                {
                    if(board[i][j] != '#')
                    {
                        int dr1 = Math.abs(i-r1);
                        int dr2 = Math.abs(i-r2);
                        int dc1 = Math.abs(j-c1);
                        int dc2 = Math.abs(j-c2);

                        if(dr1%4 == 0 && dc1%4 == 0 && dr2%4 == 0 && dc2%4 == 0)
                        {
                            ok = true;
                        }
                    }
                }
            }
            if(ok)
                System.out.println("YES");
            else
                System.out.println("NO");

            if(t > 0)
                in.nextLine();
        }
    }

    public static void exit()
    {
        System.exit(0);
    }
}

class Input
{
    BufferedReader br;
    StringTokenizer st;

    public Input()
    {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String nextLine()throws IOException
    {
       return br.readLine();
    }

    public int nextInt()throws IOException
    {
        return Integer.parseInt(next());
    }

    public long nextLong()throws IOException
    {
        return Long.parseLong(next());
    }

    public float nextFloat()throws IOException
    {
        return Float.parseFloat(next());
    }

    public double nextDouble()throws IOException
    {
        return Double.parseDouble(next());
    }

    public String next()throws IOException
    {
        if(st == null || !st.hasMoreTokens())
          st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.*;
public class SemiKnight
{
    static final int INF = Integer.MAX_VALUE;
    static final int NINF = Integer.MIN_VALUE;

    public static void main(String[]args)throws IOException
    {
        Input in = new Input();
        int t = in.nextInt();
        char [][] board = new char[8][8];
        while(t-- > 0)
        {
            for(int i = 0; i < 8; i++)
                board[i] = in.nextLine().toCharArray();

            int r1 = 0;
            int c1 = 0;
            int r2 = 0;
            int c2 = 0;
            boolean first = false;
      outer:for(int r = 0; r < 8; r++)
            {
                for(int c = 0; c < 8; c++)
                {
                    if(board[r][c] == 'K')
                    {
                        if(!first)
                        {
                            r1 = r;
                            c1 = c;
                            first = true;
                        }else
                        {
                            r2 = r;
                            c2 = c;
                            break outer;
                        }
                    }
                }
            }
            boolean ok = false;
            for(int i = 0; i < 8; i++)
            {
                for(int j = 0; j < 8; j++)
                {
                    if(board[i][j] != '#')
                    {
                        int dr1 = Math.abs(i-r1);
                        int dr2 = Math.abs(i-r2);
                        int dc1 = Math.abs(j-c1);
                        int dc2 = Math.abs(j-c2);

                        if(dr1%2 == 0 && dr2%2 == 0)
                        {
                            ok = true;
                        }
                    }
                }
            }
            if(ok)
                System.out.println("YES");
            else
                System.out.println("NO");

            if(t > 0)
                in.nextLine();
        }
    }

    public static void exit()
    {
        System.exit(0);
    }
}

class Input
{
    BufferedReader br;
    StringTokenizer st;

    public Input()
    {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String nextLine()throws IOException
    {
       return br.readLine();
    }

    public int nextInt()throws IOException
    {
        return Integer.parseInt(next());
    }

    public long nextLong()throws IOException
    {
        return Long.parseLong(next());
    }

    public float nextFloat()throws IOException
    {
        return Float.parseFloat(next());
    }

    public double nextDouble()throws IOException
    {
        return Double.parseDouble(next());
    }

    public String next()throws IOException
    {
        if(st == null || !st.hasMoreTokens())
          st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.*;
public class SemiKnight
{
    static final int INF = Integer.MAX_VALUE;
    static final int NINF = Integer.MIN_VALUE;

    public static void main(String[]args)throws IOException
    {
        Input in = new Input();
        int t = in.nextInt();
        char [][] board = new char[8][8];
        while(t-- > 0)
        {
            for(int i = 0; i < 8; i++)
                board[i] = in.nextLine().toCharArray();

            int r1 = 0;
            int c1 = 0;
            int r2 = 0;
            int c2 = 0;
            boolean first = false;
      outer:for(int r = 0; r < 8; r++)
            {
                for(int c = 0; c < 8; c++)
                {
                    if(board[r][c] == 'K')
                    {
                        if(!first)
                        {
                            r1 = r;
                            c1 = c;
                            first = true;
                        }else
                        {
                            r2 = r;
                            c2 = c;
                            break outer;
                        }
                    }
                }
            }
            boolean ok = false;
            for(int i = 0; i < 8; i++)
            {
                for(int j = 0; j < 8; j++)
                {
                    if(board[i][j] != '#')
                    {
                        int dr1 = Math.abs(i-r1);
                        int dr2 = Math.abs(i-r2);
                        int dc1 = Math.abs(j-c1);
                        int dc2 = Math.abs(j-c2);

                        if(dr1 == dc1 && dr1%2 == 0 && dc2 == dr2 && dr2%2 == 0)
                        {
                            ok = true;                        }
                    }
                }
            }
            if(ok)
                System.out.println("YES");
            else
                System.out.println("NO");

            if(t > 0)
                in.nextLine();
        }
    }

    public static void exit()
    {
        System.exit(0);
    }
}

class Input
{
    BufferedReader br;
    StringTokenizer st;

    public Input()
    {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String nextLine()throws IOException
    {
       return br.readLine();
    }

    public int nextInt()throws IOException
    {
        return Integer.parseInt(next());
    }

    public long nextLong()throws IOException
    {
        return Long.parseLong(next());
    }

    public float nextFloat()throws IOException
    {
        return Float.parseFloat(next());
    }

    public double nextDouble()throws IOException
    {
        return Double.parseDouble(next());
    }

    public String next()throws IOException
    {
        if(st == null || !st.hasMoreTokens())
          st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.TreeSet;

public class A {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		while(n-- > 0){
			char[][] board = new char[8][8];
			Pair K1 = new Pair(0,0);
			Pair K2 = new Pair(0,0);
			boolean one = false;
			for(int i = 0; i < 8; i++){
				String line = in.next();
				for(int j = 0; j < line.length(); j++){
					board[j][i] = line.charAt(j);
					if(line.charAt(j) == '#'){
						//bad.add(id(j,i));
					}
					if(line.charAt(j) == 'K' && one){
						K2 = new Pair(j,i);
					}
					if(line.charAt(j) == 'K' && !one){
						K1 = new Pair(j,i);
						one = true;
					}

				}
			}
			/*
			System.out.println("K1 = " + K1.x + " " + K1.y);
			System.out.println("K2 = " + K2.x + " " + K2.y);

			System.out.println("board:");
			for(int i = 0; i < 8; i++){
				for(int j = 0; j < 8; j++){
					System.out.print(board[j][i]);
				}
				System.out.println();

			}*/

			Queue<Pair> q = new LinkedList<Pair>();
			q.add(K1);
			//1 odd 2 par
			int[][] K1_reach = new int[8][8];
			int[][] K2_reach = new int[8][8];
			K1_reach[K1.x][K1.y] = 1;
			K2_reach[K2.x][K2.y] = 1;

			while(!q.isEmpty()){
				Pair node = q.poll();
				int x1 = node.x+2;
				int y1 = node.y+2;
				if(x1 >= 0 && x1 < 8 && y1 >=0 && y1 < 8){
					if(K1_reach[x1][y1] == 0) q.add(new Pair(x1, y1));
					if(K1_reach[node.x][node.y] == 1)K1_reach[x1][y1] = 2;
					if(K1_reach[node.x][node.y] == 2)K1_reach[x1][y1] = 1;
				}

				x1 = node.x+2;
				y1 = node.y-2;
				if(x1 >= 0 && x1 < 8 && y1 >=0 && y1 < 8){
					if(K1_reach[x1][y1] == 0) q.add(new Pair(x1, y1));
					if(K1_reach[node.x][node.y] == 1)K1_reach[x1][y1] = 2;
					if(K1_reach[node.x][node.y] == 2)K1_reach[x1][y1] = 1;
				}
				x1 = node.x-2;
				y1 = node.y-2;
				if(x1 >= 0 && x1 < 8 && y1 >=0 && y1 < 8){
					if(K1_reach[x1][y1] == 0) q.add(new Pair(x1, y1));
					if(K1_reach[node.x][node.y] == 1)K1_reach[x1][y1] = 2;
					if(K1_reach[node.x][node.y] == 2)K1_reach[x1][y1] = 1;
				}
				x1 = node.x-2;
				y1 = node.y+2;
				if(x1 >= 0 && x1 < 8 && y1 >=0 && y1 < 8){
					if(K1_reach[x1][y1] == 0) q.add(new Pair(x1, y1));
					if(K1_reach[node.x][node.y] == 1)K1_reach[x1][y1] = 2;
					if(K1_reach[node.x][node.y] == 2)K1_reach[x1][y1] = 1;
				}

			}

			q = new LinkedList<Pair>();
			q.add(K2);

			while(!q.isEmpty()){
				Pair node = q.poll();
				int x1 = node.x+2;
				int y1 = node.y+2;
				if(x1 >= 0 && x1 < 8 && y1 >=0 && y1 < 8){
					if(K2_reach[x1][y1] == 0) q.add(new Pair(x1, y1));
					if(K2_reach[node.x][node.y] == 1)K2_reach[x1][y1] = 2;
					if(K2_reach[node.x][node.y] == 2)K2_reach[x1][y1] = 1;
				}

				x1 = node.x+2;
				y1 = node.y-2;
				if(x1 >= 0 && x1 < 8 && y1 >=0 && y1 < 8){
					if(K2_reach[x1][y1] == 0) q.add(new Pair(x1, y1));
					if(K2_reach[node.x][node.y] == 1)K2_reach[x1][y1] = 2;
					if(K2_reach[node.x][node.y] == 2)K2_reach[x1][y1] = 1;
				}
				x1 = node.x-2;
				y1 = node.y-2;
				if(x1 >= 0 && x1 < 8 && y1 >=0 && y1 < 8){
					if(K2_reach[x1][y1] == 0) q.add(new Pair(x1, y1));
					if(K2_reach[node.x][node.y] == 1)K2_reach[x1][y1] = 2;
					if(K2_reach[node.x][node.y] == 2)K2_reach[x1][y1] = 1;
				}
				x1 = node.x-2;
				y1 = node.y+2;
				if(x1 >= 0 && x1 < 8 && y1 >=0 && y1 < 8){
					if(K2_reach[x1][y1] == 0) q.add(new Pair(x1, y1));
					if(K2_reach[node.x][node.y] == 1)K2_reach[x1][y1] = 2;
					if(K2_reach[node.x][node.y] == 2)K2_reach[x1][y1] = 1;
				}

			}
			/*
			System.out.println("odd/pair k1");
			for(int i = 0; i < 8; i++){
				for(int j = 0; j < 8; j++){
					System.out.print(K1_reach[j][i]);
				}
				System.out.println();

			}
			System.out.println("odd/pair k2");
			for(int i = 0; i < 8; i++){
				for(int j = 0; j < 8; j++){
					System.out.print(K2_reach[j][i]);
				}
				System.out.println();

			}
			*/
			boolean yes = false;
			for(int y = 0; y < 8; y++){
				for(int x = 0; x < 8; x++){
					if(K2_reach[x][y] != 0 && K1_reach[x][y] != 0 && K2_reach[x][y] == K1_reach[x][y] && board[x][y] != '#'){
						yes = true;
						//System.out.println("found at " + x + " " + y);
					}
				}
			}
			if(yes) System.out.println("YES");
			else System.out.println("NO");

		}
	}

	static class Pair{
		int x;
		int y;
		Pair(int xx, int yy){
			x = xx;
			y = yy;
		}
	}

}


import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		new A();
	}

	public A() {
		Scanner sc = new Scanner(System.in);

		int amount = sc.nextInt();
		for (int task = 0; task < amount; task++) {
			char[][] board = new char[8][8];
			int x1 = -1;
			int y1 = -1;
			int x2 = -1;
			int y2 = -1;
			boolean doneKnight = false;
			for (int i = 0; i < 8; i++) {
				String row = sc.next();
				for (int j = 0; j < 8; j++) {
					char d = row.charAt(j);
					board[i][j] = d;
					if (d == 'K') {
						if (!doneKnight) {
							doneKnight = true;
							x1 = i;
							y1 = j;
						} else {
							x2 = i;
							y2 = j;
						}
					}
				}
			}
			boolean poss = true;
			int diff = Math.abs(x1-x2) + Math.abs(y1-y2);
			if (diff%4 != 0) poss = false;

			if (poss) {
				int sum = (x1+y1)%4;
				boolean found = false;
				for (int i = 0; i < 8 && !found; i++) {
					for (int j = 0; j< 8; j++) {
						if ((i+j)%4 == sum && board[i][j] == '.') found = true;
					}
				}
				if (!found) poss = false;
			}

			if (poss) System.out.println("YES");
			else System.out.println("NO");
		}

		sc.close();
	}
}


import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		new A();
	}

	public A() {
		Scanner sc = new Scanner(System.in);

		int amount = sc.nextInt();
		for (int task = 0; task < amount; task++) {
			char[][] board = new char[8][8];
			int x1 = -1;
			int y1 = -1;
			int x2 = -1;
			int y2 = -1;
			boolean doneKnight = false;
			for (int i = 0; i < 8; i++) {
				String row = sc.next();
				for (int j = 0; j < 8; j++) {
					char d = row.charAt(j);
					board[i][j] = d;
					if (d == 'K') {
						if (!doneKnight) {
							doneKnight = true;
							x1 = i;
							y1 = j;
						} else {
							x2 = i;
							y2 = j;
						}
					}
				}
			}
			boolean poss = true;
			int diff = Math.abs(x1-x2) + Math.abs(y1-y2);
			if (diff%4 != 0) poss = false;

			if (poss) {
				int sum = (x1+y1)%4;
				boolean found = false;
				for (int i = 0; i < 8 && !found; i++) {
					for (int j = 0; j< 8; j++) {
						if ((i+j)%4 == sum && (board[i][j] == '.' || board[i][j] == 'K')) found = true;
					}
				}
				if (!found) poss = false;
			}

			if (poss) System.out.println("YES");
			else System.out.println("NO");
		}

		sc.close();
	}
}


import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		new A();
	}

	public A() {
		Scanner sc = new Scanner(System.in);

		int amount = sc.nextInt();
		for (int task = 0; task < amount; task++) {
			char[][] board = new char[8][8];
			int x1 = -1;
			int y1 = -1;
			int x2 = -1;
			int y2 = -1;
			boolean doneKnight = false;
			for (int i = 0; i < 8; i++) {
				String row = sc.next();
				for (int j = 0; j < 8; j++) {
					char d = row.charAt(j);
					board[i][j] = d;
					if (d == 'K') {
						if (!doneKnight) {
							doneKnight = true;
							x1 = i;
							y1 = j;
						} else {
							x2 = i;
							y2 = j;
						}
					}
				}
			}
			boolean poss = true;
			int diffX = Math.abs(x1 - x2);
			int diffY = Math.abs(y1 - y2);
			if (diffX % 4 != 0 || diffY % 4 != 0)
				poss = false;

			if (poss) {
				int sum = (x1 + y1) % 4;
				boolean found = false;
				for (int i = 0; i < 8 && !found; i++) {
					for (int j = 0; j < 8; j++) {
						if ((i + j) % 4 == sum
								&& (board[i][j] == '.' || board[i][j] == 'K'))
							found = true;
					}
				}
				if (!found)
					poss = false;
			}

			if (poss)
				System.out.println("YES");
			else
				System.out.println("NO");
		}

		sc.close();
	}
}


import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		new A();
	}

	public A() {
		Scanner sc = new Scanner(System.in);

		int amount = sc.nextInt();
		for (int task = 0; task < amount; task++) {
			char[][] board = new char[8][8];
			int x1 = -1;
			int y1 = -1;
			int x2 = -1;
			int y2 = -1;
			boolean doneKnight = false;
			for (int i = 0; i < 8; i++) {
				String row = sc.next();
				for (int j = 0; j < 8; j++) {
					char d = row.charAt(j);
					board[i][j] = d;
					if (d == 'K') {
						if (!doneKnight) {
							doneKnight = true;
							x1 = i;
							y1 = j;
						} else {
							x2 = i;
							y2 = j;
						}
					}
				}
			}
			boolean poss = true;
			int diff = Math.abs(x1-x2) + Math.abs(y1-y2);
			if (diff%4 != 0) poss = false;

			if (poss) {
				int sum = x1+y1;
				boolean found = false;
				for (int i = 0; i < 8 && !found; i++) {
					for (int j = 0; j< 8; j++) {
						if (i+j == 4 && board[i][j] == '.') found = true;
					}
				}
				if (!found) poss = false;
			}

			if (poss) System.out.println("YES");
			else System.out.println("NO");
		}

		sc.close();
	}
}