#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>

#define maxn 200
#define inf 1000000001

using namespace std;

int i, j, n, m, l, r, t;
int cnt[maxn][maxn], cnt2[maxn][maxn];
bool used[maxn][maxn], used2[maxn][maxn];
char a[maxn][maxn];
int x[maxn * maxn], y[maxn * maxn];
int u, v, u2, v2, tu, tv;
bool first;

bool valid(int u, int v)
{
    if (u > 0 && v > 0 && u <= n && v <= n)
        return true;
    return false;
}

void bfs(int u, int v)
{
    l = r = 1;
    int u2, v2;
    x[l] = u;
    used[u][v] = true;
    y[l] = v;
    cnt[u][v] = 1;
    while (l <= r)
    {
        u = x[l];
        v = y[l];

        if (!used[u - 2][v + 2] && valid(u - 2, v + 2))
        {
            tu = u - 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            used[tu][tv] = true;
            cnt[tu][tv] = cnt[u][v] + 1;
        }

        if (!used[u + 2][v + 2] && valid(u + 2, v + 2))
        {
            tu = u + 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        if (!used[u - 2][v - 2] && valid(u - 2, v - 2))
        {
            tu = u - 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        if (!used[u + 2][v - 2] && valid(u + 2, v - 2))
        {
            tu = u + 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        l++;
    }

}

void bfs2(int u, int v)
{
    l = r = 1;
    x[l] = u;
    y[l] = v;
    used2[u][v] = true;
    cnt2[u][v] = 1;
    while (l <= r)
    {
        u = x[l];
        v = y[l];

        if (!used2[u - 2][v + 2] && valid(u - 2, v + 2))
        {
            tu = u - 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u + 2][v + 2] && valid(u + 2, v + 2))
        {
            tu = u + 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u - 2][v - 2] && valid(u - 2, v - 2))
        {
            tu = u - 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u + 2][v -2] && valid(u + 2, v - 2))
        {
            tu = u + 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        l++;
    }
}

void cl()
{
    for (int i = 1; i <= n; i++)
        a[0][i] = '#', a[n + 1][i] = '#', a[i][0] = '#', a[i][n + 1] = '#';

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            cnt[i][j] = cnt2[i][j]= 0;
            used[i][j] = used2[i][j] = false;
        }
}

int main()
{

    //freopen("input.txt", "r", stdin);

    scanf("%d\n", &t);

    while (t--)
    {
        n = 8;
        first = false;
        for (i = 1; i <= n; i++)
        {
            for (j = 1; j <= n; j++)
            {
                scanf("%c", &a[i][j]);
                if (a[i][j] == 'K' && !first)
                {
                    u = i;
                    v = j;
                    first = true;
                }
                else
                if (first && a[i][j] == 'K')
                    u2 = i, v2 = j;
            }
            scanf("\n");
        }

        scanf("\n");

        cl();

        bfs(u, v);

        bfs2(u2, v2);

        string ans = "NO";
        for (i = 1; i <= n; i++)
            for (j = 1; j <= n; j++)
                if (a[i][j] != '#' && cnt[i][j] && cnt2[i][j] && cnt[i][j] && cnt[i][j] % 2 == cnt2[i][j] % 2)
                    ans = "YES";
        cout<<ans<<endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>

#define maxn 200
#define inf 1000000001

using namespace std;

int i, j, n, m, l, r, t;
int cnt[maxn][maxn], cnt2[maxn][maxn];
bool used[maxn][maxn], used2[maxn][maxn];
char a[maxn][maxn];
int x[maxn * maxn], y[maxn * maxn];
int u, v, u2, v2, tu, tv;
bool first;

bool valid(int u, int v)
{
    if (u > 0 && v > 0 && u <= n && v <= n)
        return true;
    return false;
}

void bfs(int u, int v)
{
    l = r = 1;
    int u2, v2;
    x[l] = u;
    used[u][v] = true;
    y[l] = v;
    while (l <= r)
    {
        u = x[l];
        v = y[l];

        if (!used[u - 2][v + 2] && valid(u - 2, v + 2))
        {
            tu = u - 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            used[tu][tv] = true;
            cnt[tu][tv] = cnt[u][v] + 1;
        }

        if (!used[u + 2][v + 2] && valid(u + 2, v + 2))
        {
            tu = u + 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        if (!used[u - 2][v - 2] && valid(u - 2, v - 2))
        {
            tu = u - 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        if (!used[u + 2][v - 2] && valid(u + 2, v - 2))
        {
            tu = u + 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        l++;
    }

}

void bfs2(int u, int v)
{
    l = r = 1;
    x[l] = u;
    y[l] = v;
    used2[u][v] = true;
    while (l <= r)
    {
        u = x[l];
        v = y[l];

        if (!used2[u - 2][v + 2] && valid(u - 2, v + 2))
        {
            tu = u - 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u + 2][v + 2] && valid(u + 2, v + 2))
        {
            tu = u + 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u - 2][v - 2] && valid(u - 2, v - 2))
        {
            tu = u - 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u + 2][v -2] && valid(u + 2, v - 2))
        {
            tu = u + 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        l++;
    }
}

void cl()
{
    for (int i = 1; i <= n; i++)
        a[0][i] = '#', a[n + 1][i] = '#', a[i][0] = '#', a[i][n + 1] = '#';

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            cnt[i][j] = cnt2[i][j]= 0;
            used[i][j] = used2[i][j] = false;
        }
}

int main()
{

    scanf("%d\n", &t);

    while (t--)
    {
        n = 8;
        first = false;
        for (i = 1; i <= n; i++)
        {
            for (j = 1; j <= n; j++)
            {
                scanf("%c", &a[i][j]);
                if (a[i][j] == 'K' && !first)
                {
                    u = i;
                    v = j;
                    first = true;
                }
                else
                if (first && a[i][j] == 'K')
                    u2 = i, v2 = j;
            }
            scanf("\n");
        }

        scanf("\n");

        cl();

        bfs(u, v);

        bfs2(u2, v2);

        string ans = "NO";
        for (i = 1; i <= n; i++)
            for (j = 1; j <= n; j++)
                if (a[i][j] != '#' && cnt[i][j] && cnt2[i][j] && cnt[i][j] && cnt[i][j] % 2 == cnt2[i][j] % 2)
                    ans = "YES";
        cout<<ans<<endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>

#define maxn 200
#define inf 1000000001

using namespace std;

int i, j, n, m, l, r, t;
int cnt[maxn][maxn], cnt2[maxn][maxn];
bool used[maxn][maxn], used2[maxn][maxn];
char a[maxn][maxn];
int x[maxn * maxn], y[maxn * maxn];
int u, v, u2, v2, tu, tv;
bool first;

bool valid(int u, int v)
{
    if (u > 0 && v > 0 && u <= n && v <= n)
        return true;
    return false;
}

void bfs(int u, int v)
{
	l = r = 1;
	int u2, v2;
	x[l] = u;
	used[u][v] = true;
	y[l] = v;
	while (l <= r)
	{
		u = x[l];
		v = y[l];

		if (!used[u - 2][v + 2] && valid(u - 2, v + 2))
		{
			tu = u - 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			used[tu][tv] = true;
			cnt[tu][tv] = cnt[u][v] + 1;
		}

		if (!used[u + 2][v + 2] && valid(u + 2, v + 2))
		{
			tu = u + 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		if (!used[u - 2][v - 2] && valid(u - 2, v - 2))
		{
			tu = u - 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		if (!used[u + 2][v - 2] && valid(u + 2, v - 2))
		{
			tu = u + 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		l++;
	}

}

void bfs2(int u, int v)
{
	l = r = 1;
	x[l] = u;
	y[l] = v;
	used2[u][v] = true;
	while (l <= r)
	{
		u = x[l];
		v = y[l];

		if (!used2[u - 2][v + 2] && valid(u - 2, v + 2))
		{
			tu = u - 2;
			tv = v + 2;

			r++;
			x[r] = tu;
			y[r] = tv;

			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (!used2[u + 2][v + 2] && valid(u + 2, v + 2))
		{
			tu = u + 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (!used2[u - 2][v - 2] && valid(u - 2, v - 2))
		{
			tu = u - 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (!used2[u + 2][v -2] && valid(u + 2, v - 2))
		{
			tu = u + 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		l++;
	}
}

void cl()
{
	for (int i = 1; i <= n; i++)
	 	a[0][i] = '#', a[n + 1][i] = '#', a[i][0] = '#', a[i][n + 1] = '#';

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
		{
			cnt[i][j] = cnt2[i][j]= 0;
			used[i][j] = used2[i][j] = false;
		}
}

int main()
{

	//freopen("input.txt", "r", stdin);

	scanf("%d\n", &t);

	while (t--)
	{
		n = 8;
		first = false;
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				scanf("%c", &a[i][j]);
				if (a[i][j] == 'K' && !first)
				{
					u = i;
					v = j;
					first = true;
				}
				else
				if (first && a[i][j] == 'K')
					u2 = i, v2 = j;
			}
			scanf("\n");
		}

		cl();

		bfs(u, v);

		bfs2(u2, v2);

        string ans = "NO";
		for (i = 1; i <= n; i++)
            for (j = 1; j <= n; j++)
                if (a[i][j] != '#' && cnt[i][j] && cnt[i][j] == cnt2[i][j])
                    ans = "YES";
        cout<<ans<<endl;

	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>

#define maxn 200
#define inf 1000000001

using namespace std;

int i, j, n, m, l, r, t;
int cnt[maxn][maxn], cnt2[maxn][maxn];
bool used[maxn][maxn], used2[maxn][maxn];
char a[maxn][maxn];
int x[maxn * maxn], y[maxn * maxn];
int u, v, u2, v2, tu, tv;
bool first;

bool valid(int u, int v)
{
    if (u > 0 && v > 0 && u <= n && v <= n)
        return true;
    return false;
}

void bfs(int u, int v)
{
	l = r = 1;
	int u2, v2;
	x[l] = u;
	used[u][v] = true;
	y[l] = v;
	while (l <= r)
	{
		u = x[l];
		v = y[l];

		if (!used[u - 2][v + 2] && valid(u - 2, v + 2))
		{
			tu = u - 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			used[tu][tv] = true;
			cnt[tu][tv] = cnt[u][v] + 1;
		}

		if (!used[u + 2][v + 2] && valid(u + 2, v + 2))
		{
			tu = u + 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		if (!used[u - 2][v - 2] && valid(u - 2, v - 2))
		{
			tu = u - 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		if (!used[u + 2][v - 2] && valid(u + 2, v - 2))
		{
			tu = u + 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		l++;
	}

}

void bfs2(int u, int v)
{
	l = r = 1;
	x[l] = u;
	y[l] = v;
	used2[u][v] = true;
	while (l <= r)
	{
		u = x[l];
		v = y[l];

		if (!used2[u - 2][v + 2] && valid(u - 2, v + 2))
		{
			tu = u - 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (!used2[u + 2][v + 2] && valid(u + 2, v + 2))
		{
			tu = u + 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (!used2[u - 2][v - 2] && valid(u - 2, v - 2))
		{
			tu = u - 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (!used2[u + 2][v -2] && valid(u + 2, v - 2))
		{
			tu = u + 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		l++;
	}
}

void cl()
{
	for (int i = 1; i <= n; i++)
	 	a[0][i] = '#', a[n + 1][i] = '#', a[i][0] = '#', a[i][n + 1] = '#';

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
		{
			cnt[i][j] = cnt2[i][j]= 0;
			used[i][j] = used2[i][j] = false;
		}
}

int main()
{

	//freopen("input.txt", "r", stdin);

	scanf("%d\n", &t);

	while (t--)
	{
		n = 8;
		first = false;
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				scanf("%c", &a[i][j]);
				if (a[i][j] == 'K' && !first)
				{
					u = i;
					v = j;
					first = true;
				}
				else
				if (first && a[i][j] == 'K')
					u2 = i, v2 = j;
			}
			scanf("\n");
		}

		scanf("\n");

		cl();

		bfs(u, v);

		bfs2(u2, v2);

        string ans = "NO";
		for (i = 1; i <= n; i++)
            for (j = 1; j <= n; j++)
                if (a[i][j] != '#' && cnt[i][j] && cnt[i][j] == cnt2[i][j])
                    ans = "YES";
        cout<<ans<<endl;

	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>

#define maxn 200
#define inf 1000000001

using namespace std;

int i, j, n, m, l, r, t;
int cnt[maxn][maxn], cnt2[maxn][maxn];
bool used[maxn][maxn], used2[maxn][maxn];
char a[maxn][maxn];
int x[maxn * maxn], y[maxn * maxn];
int u, v, u2, v2, tu, tv;
bool first;

bool valid(int u, int v)
{
    if (u > 0 && v > 0 && u <= n && v <= n)
        return true;
    return false;
}

void bfs(int u, int v)
{
    l = r = 1;
    int u2, v2;
    x[l] = u;
    used[u][v] = true;
    y[l] = v;
    while (l <= r)
    {
        u = x[l];
        v = y[l];

        if (!used[u - 2][v + 2] && valid(u - 2, v + 2))
        {
            tu = u - 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            used[tu][tv] = true;
            cnt[tu][tv] = cnt[u][v] + 1;
        }

        if (!used[u + 2][v + 2] && valid(u + 2, v + 2))
        {
            tu = u + 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        if (!used[u - 2][v - 2] && valid(u - 2, v - 2))
        {
            tu = u - 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        if (!used[u + 2][v - 2] && valid(u + 2, v - 2))
        {
            tu = u + 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt[tu][tv] = cnt[u][v] + 1;
            used[tu][tv] = true;
        }

        l++;
    }

}

void bfs2(int u, int v)
{
    l = r = 1;
    x[l] = u;
    y[l] = v;
    used2[u][v] = true;
    while (l <= r)
    {
        u = x[l];
        v = y[l];

        if (!used2[u - 2][v + 2] && valid(u - 2, v + 2))
        {
            tu = u - 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;

            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u + 2][v + 2] && valid(u + 2, v + 2))
        {
            tu = u + 2;
            tv = v + 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u - 2][v - 2] && valid(u - 2, v - 2))
        {
            tu = u - 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        if (!used2[u + 2][v -2] && valid(u + 2, v - 2))
        {
            tu = u + 2;
            tv = v - 2;
            r++;
            x[r] = tu;
            y[r] = tv;
            cnt2[tu][tv] = cnt2[u][v] + 1;
            used2[tu][tv] = true;
        }

        l++;
    }
}

void cl()
{
    for (int i = 1; i <= n; i++)
        a[0][i] = '#', a[n + 1][i] = '#', a[i][0] = '#', a[i][n + 1] = '#';

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            cnt[i][j] = cnt2[i][j]= 0;
            used[i][j] = used2[i][j] = false;
        }
}

int main()
{

    //freopen("input.txt", "r", stdin);

    scanf("%d\n", &t);

    while (t--)
    {
        n = 8;
        first = false;
        for (i = 1; i <= n; i++)
        {
            for (j = 1; j <= n; j++)
            {
                scanf("%c", &a[i][j]);
                if (a[i][j] == 'K' && !first)
                {
                    u = i;
                    v = j;
                    first = true;
                }
                else
                if (first && a[i][j] == 'K')
                    u2 = i, v2 = j;
            }
            scanf("\n");
        }

        scanf("\n");

        cl();

        bfs(u, v);

        bfs2(u2, v2);

        string ans = "NO";
        for (i = 1; i <= n; i++)
            for (j = 1; j <= n; j++)
                if (a[i][j] != '#' && cnt[i][j] && cnt[i][j] % 2 == cnt2[i][j] % 2)
                    ans = "YES";
        cout<<ans<<endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>

#define maxn 20
#define inf 1000000001

using namespace std;

int i, j, n, m, l, r, t;
int cnt[maxn][maxn], cnt2[maxn][maxn];
bool used[maxn][maxn], used2[maxn][maxn];
char a[maxn][maxn];
int x[maxn * maxn], y[maxn * maxn];
int u, v, u2, v2, tu, tv;
bool first;

bool ok1(int u, int v)
{
	// right up
	for (int j = v + 1; j <= v + 2; j++)
		if (a[u][j] == '#')
			return false;
	for (int i = u - 1; i <= u - 2; i++)
		if (a[i][v + 2] == '#')
			return false;
	return true;
}

bool ok2(int u, int v)
{
	// right down

	for (int j = v + 1; j <= v + 2; j++)
		if (a[u][j] == '#')
			return false;
	for (int i =u + 1; i <= u + 2; i++)
		if (a[u][v + 2] == '#')
			return false;
	return true;
}

bool ok3(int u, int v)
{
	//left up
	for (int j = v - 1; j <= v - 2; j++)
		if (a[u][j] == '#')
			return false;
	for (int i = u - 1; i <= u - 2; i++)
		if (a[i][v - 2])
			return false;
	return true;
}

bool ok4(int u, int v)
{
	//left down
	for (int j = v - 1; j <= v - 2; j++)
		if (a[u][j] == '#')
			return false;
	for (int i = u + 1; i <= u + 2; i++)
		if (a[i][v - 2])
			return false;
	return true;
}

bool valid(int u, int v)
{
    if (u && v && u <= n && v <= n)
        return true;
    return false;
}

void bfs(int u, int v)
{
	l = r = 1;
	int u2, v2;
	x[l] = u;
	used[u][v] = true;
	y[l] = v;
	while (l <= r)
	{
		u = x[l];
		v = y[l];

		if (ok1(u, v) && !used[u - 2][v + 2] && valid(u - 2, v + 2))
		{
			tu = u - 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			used[tu][tv] = true;
			cnt[tu][tv] = cnt[u][v] + 1;
		}

		if (ok2(u, v) && !used[u + 2][v + 2] && valid(u + 2, v + 2))
		{
			tu = u + 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		if (ok3(u, v) && !used[u - 2][v - 2] && valid(u - 2, v - 2))
		{
			tu = u - 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		if (ok4(u, v) && !used[u + 2][v - 2] && valid(u + 2, v - 2))
		{
			tu = u + 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;

			cnt[tu][tv] = cnt[u][v] + 1;
			used[tu][tv] = true;
		}

		l++;
	}

}

void bfs2(int u, int v)
{
	l = r = 1;
	x[l] = u;
	y[l] = v;
	used2[u][v] = true;
	while (l <= r)
	{
		u = x[l];
		v = y[l];

		if (ok1(u, v) && !used2[u - 2][v + 2] && valid(u - 2, v - 2))
		{
			tu = u - 2;
			tv = v + 2;

			r++;
			x[r] = tu;
			y[r] = tv;

			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (ok2(u, v) && !used2[u + 2][v + 2] && valid(u + 2, v + 2))
		{
			tu = u + 2;
			tv = v + 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (ok3(u, v) && !used2[u - 2][v - 2] && valid(u - 2, v - 2))
		{
			tu = u - 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		if (ok4(u, v) && !used2[u + 2][v -2] && valid(u + 2, v - 2))
		{
			tu = u + 2;
			tv = v - 2;
			r++;
			x[r] = tu;
			y[r] = tv;
			cnt2[tu][tv] = cnt2[u][v] + 1;
			used2[tu][tv] = true;
		}

		l++;
	}
}

void cl()
{
	for (i = 1; i <= n; i++)
	 	a[0][i] = '#', a[n + 1][i] = '#', a[i][0] = '#', a[i][n + 1] = '#';

	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			cnt[i][j] = cnt2[i][j]= 0;
			used[i][j] = used2[i][j] = false;
		}
}

int main()
{

	//freopen("input.txt", "r", stdin);

	scanf("%d\n", &t);

	while (t--)
	{
		n = 8;
		first = false;
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				scanf("%c", &a[i][j]);
				if (a[i][j] == 'K' && !first)
				{
					u = i;
					v = j;
					first = true;
				}
				else
				if (first && a[i][j] == 'K')
					u2 = i, v2 = j;
			}
			scanf("\n");
		}
		cl();
		bfs(u, v);

		bfs2(u2, v2);

    string ans = "NO";
		for (i = 1; i <= n; i++)
            for (j = 1; j <= n; j++)
                if (cnt[i][j]  && cnt[i][j] == cnt2[i][j])
                    ans = "YES";
        cout<<ans<<endl;

	}

	return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2];
int vis[9][9],sum[9][9];
char map[9][9];
void dfs(int x,int y,int col)
{
    if (x>0&&x<9&&y>0&&y<9&&!vis[x][y])
    {
        vis[x][y] = 1;
        sum[x][y] += col;
        dfs(x+2,y+2,col);
        dfs(x+2,y-2,col);
        dfs(x-2,y+2,col);
        dfs(x-2,y-2,col);
    }
    return;
}
int main()
{
//  freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#') sum[i][j] = inf;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    sum[i][j] = cnt;
                    vis[i][j] = 1;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        vis[st[2].x][st[2].y] = 1;
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if (sum[i][j] == 3)
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2];
int vis[9][9],sum[9][9],ju[2][9][9];
char map[9][9];
void dfs(int x,int y,int col,int step)
{
    if (x>0&&x<9&&y>0&&y<9&&!vis[x][y])
    {
        vis[x][y] = 1;
        sum[x][y] += col;
        ju[col][x][y] = step;
        dfs(x+2,y+2,col,step+1);
        dfs(x+2,y-2,col,step+1);
        dfs(x-2,y+2,col,step+1);
        dfs(x-2,y-2,col,step+1);
    }
    return;
}
int main()
{
//  freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        memset(ju,0,sizeof(ju));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#') sum[i][j] = inf;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    sum[i][j] = inf;
                }
            }
        }
        dfs(st[1].x,st[1].y,1,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2,1);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if (sum[i][j] == 3&&(ju[1][i][j]%2 == ju[2][i][j]%2))
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2],q[10000];
int vis[9][9],sum[9][9],judge[3][9][9];
char map[9][9];
int dir[4][2] = {
    2,2,-2,2,2,-2,-2,-2
};
void dfs(int x1,int y1,int col)
{
    int front = 1,rear = 2;
    q[front].x = x1;q[front].y = y1;vis[x1][y1] = 1;
    while (front<rear)
    {
        Node t = q[front];
        for (int i=0;i<4;++i)
        {
            int nx = t.x + dir[i][0];int ny = t.y + dir[i][1];
            if (nx>0&&nx<9&&ny>0&&ny<9&&!vis[nx][ny])
            {
                judge[col][nx][ny] = judge[col][t.x][t.y] + 1;
                Node temp;temp.x = nx;temp.y = ny;
                q[rear++] = temp;
            }
        }
        front++;
    }
    return;
}
int main()
{
//  freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        memset(judge,-1,sizeof(judge));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#')
                {
                    judge[0][i][j] = inf;
                    judge[1][i][j] = inf;
                }
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    judge[cnt][i][j] = 0;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if (judge[1][i][j]>-1&&judge[2][i][j]>-1&&(judge[1][i][j]%2 == judge[2][i][j]%2))
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2];
int vis[9][9],sum[9][9];
char map[9][9];
void dfs(int x,int y,int col)
{
    if (x>0&&x<9&&y>0&&y<9&&!vis[x][y])
    {
        vis[x][y] = 1;
        sum[x][y] += col;
        dfs(x+2,y+2,col);
        dfs(x+2,y-2,col);
        dfs(x-2,y+2,col);
        dfs(x-2,y-2,col);
    }
    return;
}
int main()
{
  //  freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#') sum[i][j] = inf;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    sum[i][j] = cnt;
                    vis[i][j] = 1;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if (sum[i][j] == 3)
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2],q[10000];
int vis[9][9],sum[9][9],judge[3][9][9],ba[9][9];
char map[9][9];
int dir[4][2] = {
    2,2,-2,2,2,-2,-2,-2
};
void dfs(int x1,int y1,int col)
{
    int front = 1,rear = 2;
    q[front].x = x1;q[front].y = y1;vis[x1][y1] = 1;
    while (front<rear)
    {
        Node t = q[front];
        for (int i=0;i<4;++i)
        {
            int nx = t.x + dir[i][0];int ny = t.y + dir[i][1];
            if (nx>0&&nx<9&&ny>0&&ny<9&&!vis[nx][ny])
            {
                vis[nx][ny] = 1;
                judge[col][nx][ny] = judge[col][t.x][t.y] + 1;
                Node temp;temp.x = nx;temp.y = ny;
                q[rear++] = temp;
            }
        }
        front++;
    }
    return;
}
int main()
{
//    freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        memset(judge,0,sizeof(judge));
        memset(ba,0,sizeof(ba));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#')
                    ba[i][j] = 1;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    judge[cnt][i][j] = 0;
                    ba[i][j] = 1;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if ((judge[1][i][j]>0)&&(judge[2][i][j]>0)&&(judge[1][i][j]%2 == judge[2][i][j]%2)&&!ba[i][j])
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2];
int vis[9][9],sum[9][9],ju[3][9][9];
char map[9][9];
void dfs(int x,int y,int col,int step)
{
    if (x>0&&x<9&&y>0&&y<9&&!vis[x][y])
    {
        vis[x][y] = 1;
        sum[x][y] += col;
        ju[col][x][y] = step;
        dfs(x+2,y+2,col,step+1);
        dfs(x+2,y-2,col,step+1);
        dfs(x-2,y+2,col,step+1);
        dfs(x-2,y-2,col,step+1);
    }
    return;
}
int main()
{
  //  freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        memset(ju,0,sizeof(ju));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#') sum[i][j] = inf;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    sum[i][j] = inf;
                }
            }
        }
        dfs(st[1].x,st[1].y,1,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2,1);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if (sum[i][j] == 3&&(ju[1][i][j]%2 == ju[2][i][j]%2))
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2];
int vis[9][9],sum[9][9];
char map[9][9];
void dfs(int x,int y,int col)
{
    if (x>0&&x<9&&y>0&&y<9&&!vis[x][y])
    {
        vis[x][y] = 1;
        sum[x][y] += col;
        dfs(x+2,y+2,col);
        dfs(x+2,y-2,col);
        dfs(x-2,y+2,col);
        dfs(x-2,y-2,col);
    }
    return;
}
int main()
{
  //  freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#') sum[i][j] = inf;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    sum[i][j] = cnt;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if (sum[i][j] == 3&&(i!=st[1].x&&j!=st[1].y)&&(i!=st[2].x&&j!=st[2].y))
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7f
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2];
int vis[9][9],sum[9][9];
char map[9][9];
void dfs(int x,int y,int col)
{
    if (x>0&&x<9&&y>0&&y<9&&!vis[x][y])
    {
        vis[x][y] = 1;
        sum[x][y] += col;
        dfs(x+2,y+2,col);
        dfs(x+2,y-2,col);
        dfs(x-2,y+2,col);
        dfs(x-2,y-2,col);
    }
    return;
}
int main()
{
  //  freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#') sum[i][j] = inf;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    sum[i][j] = cnt;
                    vis[i][j] = 1;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if (sum[i][j] == 3)
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2],q[10000];
int vis[9][9],sum[9][9],judge[3][9][9],ba[9][9];
char map[9][9];
int dir[4][2] = {
    2,2,-2,2,2,-2,-2,-2
};
void dfs(int x1,int y1,int col)
{
    int front = 1,rear = 2;
    q[front].x = x1;q[front].y = y1;vis[x1][y1] = 1;
    while (front<rear)
    {
        Node t = q[front];
        for (int i=0;i<4;++i)
        {
            int nx = t.x + dir[i][0];int ny = t.y + dir[i][1];
            if (nx>0&&nx<9&&ny>0&&ny<9&&!vis[nx][ny])
            {
                vis[nx][ny] = 1;
                judge[col][nx][ny] = judge[col][t.x][t.y] + 1;
                Node temp;temp.x = nx;temp.y = ny;
                q[rear++] = temp;
            }
        }
        front++;
    }
    return;
}
int main()
{
 //   freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        memset(judge,-1,sizeof(judge));
        memset(ba,0,sizeof(ba));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#')
                    ba[i][j] = 1;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    judge[cnt][i][j] = 0;
                    ba[i][j] = 1;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if ((judge[1][i][j]>-1)&&(judge[2][i][j]>-1)&&(judge[1][i][j]%2 == judge[2][i][j]%2)&&!ba[i][j])
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2],q[10000];
int vis[9][9],sum[9][9],judge[3][9][9],ba[9][9];
char map[9][9];
int dir[4][2] = {
    2,2,-2,2,2,-2,-2,-2
};
void dfs(int x1,int y1,int col)
{
    int front = 1,rear = 2;
    q[front].x = x1;q[front].y = y1;vis[x1][y1] = 1;
    while (front<rear)
    {
        Node t = q[front];
        for (int i=0;i<4;++i)
        {
            int nx = t.x + dir[i][0];int ny = t.y + dir[i][1];
            if (nx>0&&nx<9&&ny>0&&ny<9&&!vis[nx][ny])
            {
                vis[nx][ny] = 1;
                judge[col][nx][ny] = judge[col][t.x][t.y] + 1;
                Node temp;temp.x = nx;temp.y = ny;
                q[rear++] = temp;
            }
        }
        front++;
    }
    return;
}
int main()
{
  //  freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        memset(judge,-1,sizeof(judge));
        memset(ba,0,sizeof(ba));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#')
                    ba[i][j] = 1;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    judge[cnt][i][j] = 0;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if ((judge[1][i][j]>-1)&&(judge[2][i][j]>-1)&&(judge[1][i][j]%2 == judge[2][i][j]%2)&&!ba[i][j])
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


# include <cstdio>
# include <iostream>
# include <algorithm>
# include <cstring>
# define inf -0x7ffffff
using namespace std;
typedef struct NODE{
    int x,y;
}Node;
Node st[2],q[10000];
int vis[9][9],sum[9][9],judge[3][9][9],ba[9][9];
char map[9][9];
int dir[4][2] = {
    2,2,-2,2,2,-2,-2,-2
};
void dfs(int x1,int y1,int col)
{
    int front = 1,rear = 2;
    q[front].x = x1;q[front].y = y1;vis[x1][y1] = 1;
    while (front<rear)
    {
        Node t = q[front];
        for (int i=0;i<4;++i)
        {
            int nx = t.x + dir[i][0];int ny = t.y + dir[i][1];
            if (nx>0&&nx<9&&ny>0&&ny<9&&!vis[nx][ny])
            {
                judge[col][nx][ny] = judge[col][t.x][t.y] + 1;
                Node temp;temp.x = nx;temp.y = ny;
                q[rear++] = temp;
            }
        }
        front++;
    }
    return;
}
int main()
{
 //   freopen("in.txt","r",stdin);
    char a[20];
    int t,i,j,cnt;
    scanf("%d",&t);
    getchar();
    while (t--)
    {
        int flag = 0;cnt=0;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        memset(judge,-1,sizeof(judge));
        memset(ba,0,sizeof(ba));
        for (i=1;i<=8;++i)
        {
            scanf("%s",a+1);
            for (j=1;j<=8;++j)
            {
                map[i][j] = a[j];
                if (a[j] == '#')
                    ba[i][j] = 1;
                if (a[j] == 'K')
                {
                    cnt++;
                    st[cnt].x = i;
                    st[cnt].y = j;
                    judge[cnt][i][j] = 0;
                    ba[i][j] = 1;
                }
            }
        }
        dfs(st[1].x,st[1].y,1);
        memset(vis,0,sizeof(vis));
        dfs(st[2].x,st[2].y,2);
        for (i=1;i<=8;++i)
            for (j=1;j<=8;++j)
                if (judge[1][i][j]>-1&&judge[2][i][j]>-1&&(judge[1][i][j]%2 == judge[2][i][j]%2)&&!ba[i][j])
                    flag = 1;
        if (flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
using namespace std;

int t, sx, sy, ex, ey;
char g[10][10];
bool vis[10][10][10][10];

int dx[4] = {2, 2, -2, -2};
int dy[4] = {-2, 2, -2, 2};

bool inside(int x, int y)
{
    return (x >= 0 && x < 8 && y >= 0 &&y < 8);
}

bool bfs()
{
    CLR(vis, 0);
    queue<pair<int, int> > q1, q2;
    q1.push(make_pair(sx, sy));
    q2.push(make_pair(ex, ey));
    while(!q1.empty())
    {
        int x1 = q1.front().first, y1 = q1.front().second;
        int x2 = q2.front().first, y2 = q2.front().second;
        q1.pop(); q2.pop();
        if(x1 == x2 && y1 == y2 && g[x1][x2] != '#') return true;
        vis[x1][x2][y1][y2] = 1;
        REP(i, 4)
        {
            int xx1 = x1 + dx[i], yy1 = y1 + dy[i];
            int xx2 = x2 + dx[i], yy2 = y2 + dy[i];
            if(inside(xx1, yy1) && inside(xx2, yy2))
            {
                if(!vis[xx1][xx2][yy1][yy2])
                {
                    q1.push(make_pair(xx1, yy1));
                    q2.push(make_pair(xx2, yy2));
                }
            }
        }
    }
}

int main()
{
    cin>>t;
    while(t--)
    {
        sx = -1;
        REP(i, 8)
        {
            scanf("%s", g[i]);
            REP(j, 8) if(g[i][j] == 'K')
            {
                if(sx == -1) sx = i, sy = j;
                else ex = i, ey = j;
            }
        }
        printf("%s\n", bfs() ? "YES" :"NO");
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
using namespace std;

int t, sx, sy, ex, ey;
char g[10][10];
bool vis[10][10][10][10];

int dx[4] = {2, 2, -2, -2};
int dy[4] = {-2, 2, -2, 2};

bool inside(int x, int y)
{
    return (x >= 0 && x < 8 && y >= 0 && y < 8);
}

bool bfs()
{
    CLR(vis, 0);
    queue<pair<int, int> > q1, q2;
    q1.push(make_pair(sx, sy));
    q2.push(make_pair(ex, ey));
    while(!q1.empty())
    {
        int x1 = q1.front().first, y1 = q1.front().second;
        int x2 = q2.front().first, y2 = q2.front().second;
        q1.pop(); q2.pop();
        if(x1 == x2 && y1 == y2 && g[x1][y1] != '#') return true;
        vis[x1][x2][y1][y2] = 1;
        REP(i, 4)
        {
            int xx1 = x1 + dx[i], yy1 = y1 + dy[i];
            REP(j, 4)
            {
                int xx2 = x2 + dx[j], yy2 = y2 + dy[j];
                if(inside(xx1, yy1) && inside(xx2, yy2))
                {
                    if(!vis[xx1][xx2][yy1][yy2])
                    {
                        q1.push(make_pair(xx1, yy1));
                        q2.push(make_pair(xx2, yy2));
                    }
                }
            }
        }
    }
    return false;
}

int main()
{
    cin>>t;
    while(t--)
    {
        sx = -1;
        REP(i, 8)
        {
            scanf("%s", g[i]);
            REP(j, 8) if(g[i][j] == 'K')
            {
                if(sx == -1) sx = i, sy = j;
                else ex = i, ey = j;
            }
        }
        printf("%s\n", bfs() ? "YES" :"NO");
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
using namespace std;

int t, sx, sy, ex, ey;
char g[10][10];
bool vis[10][10][10][10];

int dx[4] = {2, 2, -2, -2};
int dy[4] = {-2, 2, -2, 2};

bool inside(int x, int y)
{
    return (x >= 0 && x < 8 && y >= 0 &&y < 8);
}

bool bfs()
{
    CLR(vis, 0);
    queue<pair<int, int> > q1, q2;
    q1.push(make_pair(sx, sy));
    q2.push(make_pair(ex, ey));
    while(!q1.empty())
    {
        int x1 = q1.front().first, y1 = q1.front().second;
        int x2 = q2.front().first, y2 = q2.front().second;
        q1.pop(); q2.pop();
        if(x1 == x2 && y1 == y2 && g[x1][y1] != '#')
        {
            return true;
        }
        vis[x1][x2][y1][y2] = 1;
        REP(i, 4)
        {
            int xx1 = x1 + dx[i], yy1 = y1 + dy[i];
            REP(j, 4)
            {
                int xx2 = x2 + dx[j], yy2 = y2 + dy[i];
                if(inside(xx1, yy1) && inside(xx2, yy2))
                {
                    if(!vis[xx1][xx2][yy1][yy2])
                    {
                        q1.push(make_pair(xx1, yy1));
                        q2.push(make_pair(xx2, yy2));
                    }
                }
            }
        }
    }
    return false;
}

int main()
{
    cin>>t;
    while(t--)
    {
        sx = -1;
        REP(i, 8)
        {
            scanf("%s", g[i]);
            REP(j, 8) if(g[i][j] == 'K')
            {
                if(sx == -1) sx = i, sy = j;
                else ex = i, ey = j;
            }
        }
        printf("%s\n", bfs() ? "YES" :"NO");
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
using namespace std;

int t, sx, sy, ex, ey;
char g[10][10];
bool vis[10][10];

int dx[4] = {2, 2, -2, -2};
int dy[4] = {-2, 2, -2, 2};

bool inside(int x, int y)
{
    return (x >= 0 && x < 8 && y >= 0 &&y < 8);
}

bool bfs()
{
    CLR(vis, 0);
    queue<pair<int, int> >q;
    q.push(make_pair(sx, sy));
    while(!q.empty())
    {
        int x = q.front().first, y = q.front().second;
        vis[x][y] = 1;
        q.pop();
        if(x == ex && y == ey) return true;
        REP(i, 4)
        {
            int tx = x + dx[i], ty = y + dy[i];
            if(!inside(tx, ty)) continue;
            if(!vis[tx][ty] && g[tx][ty] != '#')
                q.push(make_pair(tx, ty));
        }
    }
    return false;
}

int main()
{
    cin>>t;
    while(t--)
    {
        sx = -1;
        REP(i, 8)
        {
            scanf("%s", g[i]);
            REP(j, 8) if(g[i][j] == 'K')
            {
                if(sx == -1) sx = i, sy = j;
                else ex = i, ey = j;
            }
        }
        printf("%s\n", bfs() ? "YES" :"NO");
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
using namespace std;

int t, sx, sy, ex, ey;
char g[10][10];
bool vis[10][10][10][10];

int dx[4] = {2, 2, -2, -2};
int dy[4] = {-2, 2, -2, 2};

bool inside(int x, int y)
{
    return (x >= 0 && x < 8 && y >= 0 && y < 8);
}

bool bfs()
{
    CLR(vis, 0);
    queue<pair<int, int> > q1, q2;
    q1.push(make_pair(sx, sy));
    q2.push(make_pair(ex, ey));
    while(!q1.empty())
    {
        int x1 = q1.front().first, y1 = q1.front().second;
        int x2 = q2.front().first, y2 = q2.front().second;
        cout<<x1<<" "<<y1<<endl;
        q1.pop(); q2.pop();
        if(x1 == x2 && y1 == y2 && g[x1][y1] != '#') return true;
        vis[x1][x2][y1][y2] = 1;
        REP(i, 4)
        {
            int xx1 = x1 + dx[i], yy1 = y1 + dy[i];
            REP(j, 4)
            {
                int xx2 = x2 + dx[j], yy2 = y2 + dy[j];
                if(inside(xx1, yy1) && inside(xx2, yy2))
                {
                    if(!vis[xx1][xx2][yy1][yy2])
                    {
                        q1.push(make_pair(xx1, yy1));
                        q2.push(make_pair(xx2, yy2));
                    }
                }
            }
        }
    }
    return false;
}

int main()
{
    cin>>t;
    while(t--)
    {
        sx = -1;
        REP(i, 8)
        {
            scanf("%s", g[i]);
            REP(j, 8) if(g[i][j] == 'K')
            {
                if(sx == -1) sx = i, sy = j;
                else ex = i, ey = j;
            }
        }
        printf("%s\n", bfs() ? "YES" :"NO");
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
using namespace std;

int t, sx, sy, ex, ey;
char g[10][10];
bool vis[10][10][10][10];

int dx[4] = {2, 2, -2, -2};
int dy[4] = {-2, 2, -2, 2};

bool inside(int x, int y)
{
    return (x >= 0 && x < 8 && y >= 0 && y < 8);
}

int num1[10][10], num2[10][10];
bool vis1[10][10], vis2[10][10];

void dfs(int x, int y, int now, int num[][10], bool vis[][10])
{
    vis[x][y] = 1;
    num[x][y] = now;
    REP(i, 4)
    {
        int tx = x + dx[i];
        int ty = y + dy[i];
        if(inside(tx, ty) && !vis[tx][ty])
        {
            dfs(tx, ty, now+1, num, vis);
        }
    }
}

int main()
{
    cin>>t;
    while(t--)
    {
        CLR(vis1, 0);
        CLR(vis2, 0);
        CLR(num1, 0);
        CLR(num2, 0);
        sx = -1;
        REP(i, 8)
        {
            scanf("%s", g[i]);
            REP(j, 8) if(g[i][j] == 'K')
            {
                if(sx == -1) sx = i, sy = j;
                else ex = i, ey = j;
            }
        }
        dfs(sx, sy, 0, num1, vis1);
        dfs(ex, ey, 0, num2, vis2);
        bool flag = 0;
        REP(i, 8) REP(j, 8) if(g[i][j] != '#')
        {
            if(vis1[i][j] && vis2[i][j])
                if((num1[i][j]&1) == (num2[i][j]&1))
            {
                flag = 1;
                break;
            }
        }
        printf("%s\n", flag ? "YES" :"NO");
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
using namespace std;

int t, sx, sy, ex, ey;
char g[10][10];
bool vis[10][10][10][10];

int dx[4] = {2, 2, -2, -2};
int dy[4] = {-2, 2, -2, 2};

bool inside(int x, int y)
{
    return (x >= 0 && x < 8 && y >= 0 &&y < 8);
}

bool bfs()
{
    CLR(vis, 0);
    queue<pair<int, int> > q1, q2;
    q1.push(make_pair(sx, sy));
    q2.push(make_pair(ex, ey));
    while(!q1.empty())
    {
        int x1 = q1.front().first, y1 = q1.front().second;
        int x2 = q2.front().first, y2 = q2.front().second;
        q1.pop(); q2.pop();
        if(x1 == x2 && y1 == y2 && g[x1][x2] != '#') return true;
        vis[x1][x2][y1][y2] = 1;
        REP(i, 4)
        {
            int xx1 = x1 + dx[i], yy1 = y1 + dy[i];
            REP(j, 4)
            {
                int xx2 = x2 + dx[j], yy2 = y2 + dy[i];
                if(inside(xx1, yy1) && inside(xx2, yy2))
                {
                    if(!vis[xx1][xx2][yy1][yy2])
                    {
                        q1.push(make_pair(xx1, yy1));
                        q2.push(make_pair(xx2, yy2));
                    }
                }
            }
        }
    }
    return false;
}

int main()
{
    cin>>t;
    while(t--)
    {
        sx = -1;
        REP(i, 8)
        {
            scanf("%s", g[i]);
            REP(j, 8) if(g[i][j] == 'K')
            {
                if(sx == -1) sx = i, sy = j;
                else ex = i, ey = j;
            }
        }
        printf("%s\n", bfs() ? "YES" :"NO");
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#define REP(i, n) for(int i=0; i<n; i++)
#define CLR(a, b) memset(a, b, sizeof(a))
using namespace std;

int t, sx, sy, ex, ey;
char g[10][10];
bool vis[10][10][10][10];

int dx[4] = {2, 2, -2, -2};
int dy[4] = {-2, 2, -2, 2};

bool inside(int x, int y)
{
    return (x >= 0 && x < 8 && y >= 0 &&y < 8);
}

bool bfs()
{
    CLR(vis, 0);
    queue<pair<int, int> > q1, q2;
    q1.push(make_pair(sx, sy));
    q2.push(make_pair(ex, ey));
    while(!q1.empty())
    {
        int x1 = q1.front().first, y1 = q1.front().second;
        int x2 = q2.front().first, y2 = q2.front().second;
        q1.pop(); q2.pop();
        if(x1 == x2 && y1 == y2 && g[x1][x2] != '#') return true;
        vis[x1][x2][y1][y2] = 1;
        REP(i, 4)
        {
            int xx1 = x1 + dx[i], yy1 = y1 + dy[i];
            REP(j, 4)
            {
                int xx2 = x2 + dx[j], yy2 = y2 + dy[i];
                if(inside(xx1, yy1) && inside(xx2, yy2))
                {
                    if(!vis[xx1][xx2][yy1][yy2])
                    {
                        q1.push(make_pair(xx1, yy1));
                        q2.push(make_pair(xx2, yy2));
                    }
                }
            }
        }
    }
}

int main()
{
    cin>>t;
    while(t--)
    {
        sx = -1;
        REP(i, 8)
        {
            scanf("%s", g[i]);
            REP(j, 8) if(g[i][j] == 'K')
            {
                if(sx == -1) sx = i, sy = j;
                else ex = i, ey = j;
            }
        }
        printf("%s\n", bfs() ? "YES" :"NO");
    }
    return 0;
}


#include<iostream>
using namespace std;
const int size=8;

int maps[size][size];
bool visited[size][size];
bool isSecond;

bool isPoint(int x, int y){
 if(x<0 || x>=8 || y<0 || y>=8)
  return false;
 return true;
}

bool dfs(int x, int y){
 visited[x][y]=true;
 int i, p, q, direc[][2]={2,2,2,-2,-2,2,-2,-2};
 for(i=0; i<4; ++i){
  p=x+direc[i][0];
  q=y+direc[i][1];
  if(isPoint(p,q) && !visited[p][q]){
   if(isSecond && maps[p][q]==2)
    return true;
   if(!isSecond && maps[p][q]==1)
    maps[p][q]=2;
   if(dfs(p,q)) return true;
  }
 }
 return false;
}

void init(){
 for(int i=0; i<size; ++i)
  for(int j=0; j<size; ++j) visited[i][j]=false;
}
int main(){
 int i,j,n,x1,x2,y1,y2;
 bool isOne;
 cin>>n;
 while(n--){
  isSecond=false;
  isOne=true;
  init();
  char str[10];
  for(i=0; i<size; ++i){
   cin>>str;
   for(j=0; j<size; ++j){
    if(str[j]=='.') maps[i][j]=1;
    else maps[i][j]=0;
    if(str[j]=='K'){
     if(isOne) x1=i,y1=j,isOne=false;
     else x2=i,y2=j;
    }
   }
  }
  dfs(x1,y1);
  init();
  isSecond=true;
  if(dfs(x2,y2))
   cout<<"YES\n";
  else
   cout<<"NO\n";
 }
 return 0;
}


#include<iostream>
using namespace std;
const int size=8;

int maps[size][size];
bool visited[size][size];
bool isSecond;

bool isPoint(int x, int y){
 if(x<0 || x>=8 || y<0 || y>=8)
  return false;
 return true;
}

bool dfs(int x, int y){
 visited[x][y]=true;
 if(isSecond && maps[x][y]==2)
    return true;
 int i, p, q, direc[][2]={2,2,2,-2,-2,2,-2,-2};
 for(i=0; i<4; ++i){
  p=x+direc[i][0];
  q=y+direc[i][1];
  if(isPoint(p,q) && !visited[p][q]){
   if(!isSecond && maps[p][q]==1) maps[p][q]=2;
   if(dfs(p,q)) return true;
  }
 }
 return false;
}

void init(){
 for(int i=0; i<size; ++i)
  for(int j=0; j<size; ++j) visited[i][j]=false;
}
int main(){
 int i,j,n,x1,x2,y1,y2;
 bool isOne;
 cin>>n;
 while(n--){
  isOne=true;
  char str[10];
  for(i=0; i<size; ++i){
   cin>>str;
   for(j=0; j<size; ++j){
    if(str[j]=='#') maps[i][j]=0;
    else maps[i][j]=1;
    if(str[j]=='K'){
     if(isOne) x1=i,y1=j,isOne=false;
     else x2=i,y2=j;
    }
   }
  }
  init();
  isSecond=false;
  maps[x1][y1]=2;
  dfs(x1,y1);
  init();
  isSecond=true;
  if(dfs(x2,y2))
   cout<<"YES\n";
  else
   cout<<"NO\n";
 }
 return 0;
}


#include<iostream>
using namespace std;
const int size=8;

int maps[size][size];
bool visited[size][size];
bool isSecond;

bool isPoint(int x, int y){
 if(x<0 || x>=8 || y<0 || y>=8)
  return false;
 return true;
}

bool dfs(int x, int y){
 visited[x][y]=true;
 if(isSecond && maps[x][y]==2)
    return true;
 int i, p, q, direc[][2]={2,2,2,-2,-2,2,-2,-2};
 for(i=0; i<4; ++i){
  p=x+direc[i][0];
  q=y+direc[i][1];
  if(isPoint(p,q) && !visited[p][q]){
   if(!isSecond && maps[p][q]==1)
    maps[p][q]=2;
   if(dfs(p,q)) return true;
  }
 }
 return false;
}

void init(){
 for(int i=0; i<size; ++i)
  for(int j=0; j<size; ++j) visited[i][j]=false;
}
int main(){
 int i,j,n,x1,x2,y1,y2;
 bool isOne;
 cin>>n;
 while(n--){
  isSecond=false;
  isOne=true;
  init();
  char str[10];
  for(i=0; i<size; ++i){
   cin>>str;
   for(j=0; j<size; ++j){
    if(str[j]=='#') maps[i][j]=0;
    else maps[i][j]=1;
    if(str[j]=='K'){
     if(isOne) x1=i,y1=j,isOne=false;
     else x2=i,y2=j;
    }
   }
  }
  dfs(x1,y1);
  init();
  isSecond=true;
  if(dfs(x2,y2))
   cout<<"YES\n";
  else
   cout<<"NO\n";
 }
 return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
const int size=8;
int main(){
 int n,i,j,k,posX[2],posY[2];
 cin>>n;
 while(n--){
  char str[10];
  k=0;
  for(i=0;i<size;++i){
   cin>>str;
   for(j=0;j<size;++j){
    if(str[j]=='K'){
     posX[k]=i,posY[k++]=j;
    }
   }
  }
  if( abs(posX[0]-posX[1])%4==0 && abs(posY[0]-posY[1])%4==0 ) cout<<"YES\n";
  else cout<<"NO\n";
 }

 return 0;
}


#include<iostream>
using namespace std;
const int size=8;

int maps[size][size];
bool visited[size][size];
bool isSecond;

bool isPoint(int x, int y){
 if(x<0 || x>=8 || y<0 || y>=8)
  return false;
 return true;
}

bool dfs(int x, int y){
 visited[x][y]=true;
 int i, p, q, direc[][2]={2,2,2,-2,-2,2,-2,-2};
 for(i=0; i<4; ++i){
  p=x+direc[i][0];
  q=y+direc[i][1];
  if(isPoint(p,q) && !visited[p][q]){
   if(isSecond && maps[p][q]==2)
    return true;
   if(maps[p][q]==1){
    maps[p][q]=2;
    if(dfs(p,q)) return true;
   }
  }
 }
 return false;
}

void init(){
 for(int i=0; i<size; ++i)
  for(int j=0; j<size; ++j) visited[i][j]=false;
}
int main(){
 int i,j,n,x1,x2,y1,y2;
 bool isOne;
 cin>>n;
 while(n--){
  isSecond=false;
  isOne=true;
  init();
  char str[10];
  for(i=0; i<size; ++i){
   cin>>str;
   for(j=0; j<size; ++j){
    if(str[j]=='.') maps[i][j]=1;
    else maps[i][j]=0;
    if(str[j]=='K'){
     if(isOne) x1=i,y1=j,isOne=false;
     else x2=i,y2=j;
    }
   }
  }
  dfs(x1,y1);
  init();
  if(dfs(x2,y2))
   cout<<"YES\n";
  else
   cout<<"NO\n";
 }
 return 0;
}


#include<iostream>
using namespace std;
const int size=8;

int maps[size][size];
bool visited[size][size];
bool isSecond;

bool isPoint(int x, int y){
 if(x<0 || x>=8 || y<0 || y>=8)
  return false;
 return true;
}

bool dfs(int x, int y){
 visited[x][y]=true;
 int i, p, q, direc[][2]={2,2,2,-2,-2,2,-2,-2};
 for(i=0; i<4; ++i){
  p=x+direc[i][0];
  q=y+direc[i][1];
  if(isPoint(p,q) && !visited[p][q]){
   if(isSecond && maps[p][q]==2)
    return true;
   if(!isSecond && maps[p][q]==1)
    maps[p][q]=2;
   if(dfs(p,q)) return true;
  }
 }
 return false;
}

void init(){
 for(int i=0; i<size; ++i)
  for(int j=0; j<size; ++j) visited[i][j]=false;
}
int main(){
 int i,j,n,x1,x2,y1,y2;
 bool isOne;
 cin>>n;
 while(n--){
  isSecond=false;
  isOne=true;
  init();
  char str[10];
  for(i=0; i<size; ++i){
   cin>>str;
   for(j=0; j<size; ++j){
    if(str[j]=='#') maps[i][j]=0;
    else maps[i][j]=1;
    if(str[j]=='K'){
     if(isOne) x1=i,y1=j,isOne=false;
     else x2=i,y2=j;
    }
   }
  }
  dfs(x1,y1);
  init();
  isSecond=true;
  if(dfs(x2,y2))
   cout<<"YES\n";
  else
   cout<<"NO\n";
 }
 return 0;
}


#include<iostream>
using namespace std;
const int size=8;

int maps[size][size];
bool visited[size][size];
bool isSecond;

bool isPoint(int x, int y){
 if(x<0 || x>=8 || y<0 || y>=8)
  return false;
 return true;
}

bool dfs(int x, int y){
 visited[x][y]=true;
 int i, p, q, direc[][2]={2,2,2,-2,-2,2,-2,-2};
 for(i=0; i<4; ++i){
  p=x+direc[i][0];
  q=y+direc[i][1];
  if(isPoint(p,q) && !visited[p][q]){
   if(isSecond && maps[p][q]==2)
    return true;
   if(maps[p][q]==1){
    maps[p][q]=2;
    if(dfs(p,q)) return true;
   }
  }
 }
 return false;
}

void init(){
 for(int i=0; i<size; ++i)
  for(int j=0; j<size; ++j) visited[i][j]=false;
}
int main(){
 int i,j,n,x1,x2,y1,y2;
 bool isOne;
 cin>>n;
 while(n--){
  isSecond=false;
  isOne=true;
  init();
  char str[10];
  for(i=0; i<size; ++i){
   cin>>str;
   for(j=0; j<size; ++j){
    if(str[j]=='.') maps[i][j]=1;
    else maps[i][j]=0;
    if(str[j]=='K'){
     if(isOne) x1=i,y1=j,isOne=false;
     else x2=i,y2=j;
    }
   }
  }
  dfs(x1,y1);
  init();
  isSecond=true;
  if(dfs(x2,y2))
   cout<<"YES\n";
  else
   cout<<"NO\n";
 }
 return 0;
}


#include<iostream>
using namespace std;
const int size=8;
int abs(int x){
  if(x<0) return -x;
  return x;
}
int main(){
 int n,i,j,k,posX[2],posY[2];
 cin>>n;
 while(n--){
  char str[10];
  k=0;
  for(i=0;i<size;++i){
   cin>>str;
   for(j=0;j<size;++j){
    if(str[j]=='K'){
     posX[k]=i,posY[k++]=j;
    }
   }
  }
  if( abs(posX[0]-posX[1])%4==0 && abs(posY[0]-posY[1])%4==0 ) cout<<"YES\n";
  else cout<<"NO\n";
 }

 return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)

template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.x << ", " << a.y << ")";
}

template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = 1e9;
const li INF64 = 1e18;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1.0);
const ld EPS = 1e-9;

mt19937 rnd(time(NULL));
mt19937_64 rnd64(time(NULL));

const int N = 8;

string s[N];

bool read() {
	static char buf[15];
	if (scanf("%s", buf) != 1)
		return false;
	s[0] = buf;
	fore(i, 1, N){
		scanf("%s", buf);
		s[i] = buf;
	}
	return true;
}

int dx[] = {-2, 2, 2, -2};
int dy[] = {2, 2, -2, -2};

bool in(int x, int y){
	return (0 <= x && x < N && 0 <= y && y < N);
}

bool ok[N][N][N][N];

bool bfs(pt p1, pt p2){
	queue<pair<pt, pt>> q;
	ok[p1.x][p1.y][p2.x][p2.y] = true;
	q.push(mp(p1, p2));
	while (!q.empty()){
		pt p1 = q.front().x;
		pt p2 = q.front().y;
		q.pop();
		if (p1 == p2 && s[p1.x][p1.y] != '#') return true;
		forn(i, 4) forn(j, 4){
			int nx1 = p1.x + dx[i];
			int ny1 = p1.y + dy[i];
			int nx2 = p2.x + dx[j];
			int ny2 = p2.y + dy[j];
			if (in(nx1, ny1) && in(nx2, ny2) && !ok[nx1][ny1][nx2][ny2]){
				q.push(mp(mp(nx1, ny1), mp(nx2, ny2)));
				ok[nx1][ny1][nx2][ny2] = true;
			}
		}
	}
	return false;
}

void solve() {
	memset(ok, 0, sizeof(ok));
	int cnt = 0;
	pt p1, p2;
	forn(i, N) forn(j, N) if (s[i][j] == 'K'){
		++cnt;
		if (cnt == 1)
			p1 = mp(i, j);
		else
			p2 = mp(i, j);
	}
	puts(bfs(p1, p2) ? "YES" : "NO");
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int tt = clock();
#endif

	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(10);

	int tc;
	scanf("%d", &tc);
	while (tc--){
		read();
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
}


#include<bits/stdc++.h>
using namespace std;
char c;

int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int f=1;int x,y,x2,y2;
        for(int i=0;i<8;i++)
        for(int j=0;j<8;j++)
        {
            cin>>c;
            if(c=='K'&&f)
            {
                x=i;
                y=j;
                f=0;
            }
            else if(c=='K')
                x2=i,y2=j;
        }
        (((x2-x)%4==0)&&((y2-y)%4==0))?cout<<"YES\n":cout<<"NO\n";

    }
    return 0;
}


#include <bits/stdc++.h>
#define ll unsigned long long

using namespace std;
char m[9][9];
bool f(int x)
{
    return x>0&&x<9;
}
int main()
{

    int tc;
    cin>>tc;
    while(tc--)
    {
        int x1=8,y1=8,x2=1,y2=1;
        for(int i=1;i<9;i++)
        {
            for(int j=1;j<9;j++)
            {
                cin>>m[i][j];
                if(m[i][j]=='K')
                {
                    x1=min(x1,i);
                    y1=min(y1,j);
                    x2=max(x2,i);
                    y2=max(y2,j);
                }
            }
        }

        if(abs(x2-x1)%4==0&&abs(y2-y1)%4==0)cout<<"YES\n";
        else cout<<"NO\n";

    }

    return 0;
}


/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int tt;

    cin >> tt;
        pair<int,int> knight[2];

    for (int u=0;u<tt;u++){

    char t[8][8];
    int k=0;
    for(int i=0;i<8;i++){
        for(int j=0; j<8;j++) {

            cin >> t[i][j];
            if(t[i][j]=='K') {
            knight[k].first=i;
            knight[k].second=j;
            k++;
                             }

        }
    }
        int poskx1=knight[0].first +1;
        int posky1=knight[0].second +1;

        int poskx2=knight[1].first +1;
        int posky2=knight[1].second +1;

            int s1=poskx1+posky1;
            int s2=poskx2+posky2;

            if(abs(poskx1-poskx2) %4==0 && abs(posky1-posky2)==0) cout << "YES" ;
            else cout << "NO" ;

            if(u<tt-1) cout << "\n";
                        }
    return 0;
}


/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int tt;

    cin >> tt;
        pair<int,int> knight[2];

    for (int u=0;u<tt;u++){

    char t[8][8];
    int k=0;
    for(int i=0;i<8;i++){
        for(int j=0; j<8;j++) {

            cin >> t[i][j];
            if(t[i][j]=='K') {
            knight[k].first=i;
            knight[k].second=j;
            k++;
                             }

        }
    }
        int poskx1=knight[0].first +1;
        int posky1=knight[0].second +1;

        int poskx2=knight[1].first +1;
        int posky2=knight[1].second +1;

            int s1=poskx1+posky1;
            int s2=poskx2+posky2;

            if( (abs(s1-s2)==4 || abs(s1-s2)==0) && ( (abs(poskx1-poskx2)%2==0) || (abs(posky1-posky2)%2==0)  )) {
                    int state=0;
                            for(int i=0;i<8;i++){
                                for(int j=0;j<8;j++){
                                     if(t[i][j]=='.') {

                                         int pospx=i+1;
                                         int pospy=j+1;
                                         int sp=pospx+pospy;
                                         if(abs(s1-sp)==4 || abs(s1-sp)==0  && ((abs(poskx1-pospx)%2==0) || (abs(posky1-pospy)%2==0))    ) {
                                                state=1;
                                                break;
                                                                            }

                                                        }
                                                    }
                                    if(state==1) break;
                                                }
                                if(state==1) cout << "YES" ;
                                else cout << "NO";
                                               }
            else cout << "NO" ;

            if(u<tt-1) cout << "\n";
                        }
    return 0;
}


/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int tt;

    cin >> tt;
        pair<int,int> knight[2];

    for (int u=0;u<tt;u++){

    char t[8][8];
    int k=0;
    for(int i=0;i<8;i++){
        for(int j=0; j<8;j++) {

            cin >> t[i][j];
            if(t[i][j]=='K') {
            knight[k].first=i;
            knight[k].second=j;
            k++;
                             }

        }
    }
        int poskx1=knight[0].first +1;
        int posky1=knight[0].second +1;

        int poskx2=knight[1].first +1;
        int posky2=knight[1].second +1;

            int s1=poskx1+posky1;
            int s2=poskx2+posky2;

            if(abs(s1-s2)==4 || abs(s1-s2)==0) {
                    int state=0;
                            for(int i=0;i<8;i++){
                                for(int j=0;j<8;j++){
                                     if(t[i][j]=='.') {

                                         int pospx=i+1;
                                         int pospy=j+1;
                                         int sp=pospx+pospy;
                                         if(abs(s1-sp)==4 || abs(s1-sp)==0) {
                                                state=1;
                                                break;
                                                                            }

                                                        }
                                                    }
                                    if(state==1) break;
                                                }
                                if(state==1) cout << "YES" ;
                                else cout << "NO";
                                               }
            else cout << "NO" ;

            if(u<tt-1) cout << "\n";
                        }
    return 0;
}


/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int tt;

    cin >> tt;
        pair<int,int> knight[2];

    for (int u=0;u<tt;u++){

    char t[8][8];
    int k=0;
    for(int i=0;i<8;i++){
        for(int j=0; j<8;j++) {

            cin >> t[i][j];
            if(t[i][j]=='K') {
            knight[k].first=i;
            knight[k].second=j;
            k++;
                             }

        }
    }
        int poskx1=knight[0].first +1;
        int posky1=knight[0].second +1;

        int poskx2=knight[1].first +1;
        int posky2=knight[1].second +1;

            int s1=poskx1+posky1;
            int s2=poskx2+posky2;

            if( (abs(s1-s2)%4==0 || abs(s1-s2)==0) && ( (abs(poskx1-poskx2)%2==0) || (abs(posky1-posky2)%2==0)  )) {
                    int state=0;
                            for(int i=0;i<8;i++){
                                for(int j=0;j<8;j++){
                                     if(t[i][j]=='.') {

                                         int pospx=i+1;
                                         int pospy=j+1;
                                         int sp=pospx+pospy;
                                         if(abs(s1-sp)%4==0 || abs(s1-sp)==0  && ((abs(poskx1-pospx)%2==0) || (abs(posky1-pospy)%2==0))    ) {
                                                state=1;
                                                break;
                                                                            }

                                                        }
                                                    }
                                    if(state==1) break;
                                                }
                                if(state==1) cout << "YES" ;
                                else cout << "NO";
                                               }
            else cout << "NO" ;

            if(u<tt-1) cout << "\n";
                        }
    return 0;
}


/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int tt;

    cin >> tt;
        pair<int,int> knight[2];

    for (int u=0;u<tt;u++){

    char t[8][8];
    int k=0;
    for(int i=0;i<8;i++){
        for(int j=0; j<8;j++) {

            cin >> t[i][j];
            if(t[i][j]=='K') {
            knight[k].first=i;
            knight[k].second=j;
            k++;
                             }

        }
    }
        int poskx1=knight[0].first +1;
        int posky1=knight[0].second +1;

        int poskx2=knight[1].first +1;
        int posky2=knight[1].second +1;

            int s1=poskx1+posky1;
            int s2=poskx2+posky2;

            if(abs(s1-s2)==4 || abs(s1-s2)==0) {
                    int state=0;
                            for(int i=0;i<8;i++){
                                for(int j=0;j<8;j++){
                                     if(t[i][j]=='.') {

                                         int pospx=i+1;
                                         int pospy=j+1;
                                         int sp=pospx+pospy;
                                         if(abs(s1-sp)==4 || abs(s1-sp)==0) {
                                                state=1;
                                                break;
                                                                            }

                                                        }
                                                    }
                                    if(state==1) break;
                                                }
                                if(state==1) cout << "YES" ;
                                else cout << "NO";
                                               }
            else cout << "NO" ;

                        }
    return 0;
}


/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int tt;

    cin >> tt;
        pair<int,int> knight[2];

    for (int u=0;u<tt;u++){

    char t[8][8];
    int k=0;
    for(int i=0;i<8;i++){
        for(int j=0; j<8;j++) {

            cin >> t[i][j];
            if(t[i][j]=='K') {
            knight[k].first=i;
            knight[k].second=j;
            k++;
                             }

        }
    }
        int poskx1=knight[0].first +1;
        int posky1=knight[0].second +1;

        int poskx2=knight[1].first +1;
        int posky2=knight[1].second +1;

            int s1=poskx1+posky1;
            int s2=poskx2+posky2;

            if(abs(poskx1-poskx2) %4==0 && abs(posky1-posky2)%4==0) cout << "YES" ;
            else cout << "NO" ;

            if(u<tt-1) cout << "\n";
                        }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll ,ll >
#define vi          vector<ll >
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell       1000000007
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define rep0(a)     for(ll i=0;i<a;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define itr(a,it)          for(typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define double        long double
using namespace std;
#define N  100005
#define M 1e9
map<char,int>m;
set<char>notpr;
string s;
int l=0,r=0;
void pr()
{
    rep0(sz(s))
    {
        if(s[i]=='?')
        {
            if(i>=l && i<r)
            {
                cout<<*notpr.begin();
                notpr.erase(notpr.begin());
            }
            else
                cout<<'M';
        }
        else cout<<s[i];
    }

}
void solve()
{
   char b[10][10];
   int x1,y1,x2,y2,c=0;
   rep0(8)
   {
       rep(j,0,8)
      {
        cin>>b[i][j];
       if(b[i][j]=='K')
       {if(c==0) {x1=i; y1=j; c++;}
       else {x2=i; y2=j;}}}
   }
   if(x1%2!=x2%2 || y1%2!=y2%2 || (abs(x1-x2)+abs(y2-y1))%4!=0)
   {
       cout<<"NO"<<endl; return;
   }
   int a=x1-(x1%2);
   a+=(y1-(y1%2));
   y1=y1%2+a%4;
   x1=x1%2;
   vector<vi >vis(10,vi(10,0LL));
   queue<pii>q;
   q.push({x1,y1});
   while(!q.empty())
    {
        int x=q.front().F;
        int y=q.front().S;
        q.pop();
        vis[x][y]=1;
        if(b[x][y]=='.')
        {
            cout<<"YES"<<endl;
            return;
        }
        for(auto i:{2,-2})
            {
                for(auto j:{2,-2})
                    {
                        if(0<=(x+i) && x+i<8 && 0<=y+j && y+j<8 && vis[x+i][y+j]==0)
                        {
                             if(b[x+i][y+j]=='.')
                             {
                                cout<<"YES"<<endl; return;
                             }
                             q.push({x+i,y+j});
                             vis[x+i][y+j]=1;
                        }
                    }
            }
    }
    cout<<"NO"<<endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int TESTS=1;
    cin>>TESTS;
    while(TESTS--)
    {
       solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll ,ll >
#define vi          vector<ll >
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell       1000000007
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define rep0(a)     for(ll i=0;i<a;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define itr(a,it)          for(typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define double        long double
using namespace std;
#define N  100005
#define M 1e9
map<char,int>m;
set<char>notpr;
string s;
int l=0,r=0;
void pr()
{
    rep0(sz(s))
    {
        if(s[i]=='?')
        {
            if(i>=l && i<r)
            {
                cout<<*notpr.begin();
                notpr.erase(notpr.begin());
            }
            else
                cout<<'M';
        }
        else cout<<s[i];
    }

}
void solve()
{
   char b[10][10];
   int x1,y1,x2,y2,c=0;
   rep0(8)
   {
       rep(j,0,8)
      {
        cin>>b[i][j];
       if(b[i][j]=='K')
       {if(c==0) {x1=i; y1=j; c++;}
       else {x2=i; y2=j;}
           b[i][j]='.';
       }}
   }
   if(x1%2!=x2%2 || y1%2!=y2%2 || (abs(x1-x2)+abs(y2-y1))%4!=0)
   {
       cout<<"NO"<<endl; return;
   }
   int a=x1-(x1%2);
   a+=(y1-(y1%2));
   y1=y1%2+a%4;
   x1=x1%2;
   vector<vi >vis(10,vi(10,0LL));
   queue<pii>q;
   q.push({x1,y1});
   while(!q.empty())
    {
        int x=q.front().F;
        int y=q.front().S;
        q.pop();
        vis[x][y]=1;
       // cout<<x<<" "<<y<<" "<<b[x][y]<<endl;
        if(b[x][y]=='.')
        {
            cout<<"YES"<<endl;
            return;
        }
        for(auto i:{2,-2})
            {
                for(auto j:{2,-2})
                    {
                        if(0<=(x+i) && x+i<8 && 0<=y+j && y+j<8 && vis[x+i][y+j]==0)
                        {
                             if(b[x+i][y+j]=='.')
                             {
                                cout<<"YES"<<endl; return;
                             }
                             q.push({x+i,y+j});
                             vis[x+i][y+j]=1;
                        }
                    }
            }
    }
    cout<<"NO"<<endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int TESTS=1;
    cin>>TESTS;
    while(TESTS--)
    {
       solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll ,ll >
#define vi          vector<ll >
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell       1000000007
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define rep0(a)     for(ll i=0;i<a;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define itr(a,it)          for(typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define double        long double
using namespace std;
#define N  100005
#define M 1e9
map<char,int>m;
set<char>notpr;
string s;
int l=0,r=0;
void pr()
{
    rep0(sz(s))
    {
        if(s[i]=='?')
        {
            if(i>=l && i<r)
            {
                cout<<*notpr.begin();
                notpr.erase(notpr.begin());
            }
            else
                cout<<'M';
        }
        else cout<<s[i];
    }

}
void solve()
{
   char b[10][10];
   int x1,y1,x2,y2,c=0;
   rep0(8)
   {
       rep(j,0,8)
      {
        cin>>b[i][j];
       if(b[i][j]=='K')
       {if(c==0) {x1=i; y1=j; c++;}
       else {x2=i; y2=j;}
           b[i][j]='.';
       }}
   }
   if(x1%2!=x2%2 || y1%2!=y2%2 || abs(x1-x2)%4!=0 || abs(y2-y1)%4!=0)
   {
       cout<<"NO"<<endl; return;
   }
   int a=x1-(x1%2);
   a+=(y1-(y1%2));
   y1=y1%2+a%4;
   x1=x1%2;
   vector<vi >vis(10,vi(10,0LL));
   queue<pii>q;
   q.push({x1,y1});
   while(!q.empty())
    {
        int x=q.front().F;
        int y=q.front().S;
        q.pop();
        vis[x][y]=1;
       // cout<<x<<" "<<y<<" "<<b[x][y]<<endl;
        if(b[x][y]=='.')
        {
            cout<<"YES"<<endl;
            return;
        }
        for(auto i:{2,-2})
            {
                for(auto j:{2,-2})
                    {
                        if(0<=(x+i) && x+i<8 && 0<=y+j && y+j<8 && vis[x+i][y+j]==0)
                        {
                             if(b[x+i][y+j]=='.')
                             {
                                cout<<"YES"<<endl; return;
                             }
                             q.push({x+i,y+j});
                             vis[x+i][y+j]=1;
                        }
                    }
            }
    }
    cout<<"NO"<<endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int TESTS=1;
    cin>>TESTS;
    while(TESTS--)
    {
       solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
bool comp(pair<ll,ll>&a,pair<ll,ll>&b){
return min(2*a.first,a.second)-a.first > min(2*b.first,b.second)-b.first;
}
ll const mod=1e9+7;
ll add(ll w,ll z){
    return ((w%mod)*(z%mod))%mod;
}
void solve(){
  char a[9][9];
for(int i=0;i<8;i++){
  for(int j=0;j<8;j++){
    cin>>a[i][j];
  }
}
vector<pair<int,int>>v;
for(int i=0;i<8;i++){
  for(int j=0;j<8;j++){
   if(a[i][j]=='K')v.push_back({i,j});
  }
}
if((abs(v[0].first-v[1].first)%4==0) and (abs(v[0].second-v[1].second)%4==0))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
int main(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
     clock_t zzzz = clock();
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
      t=1;
    cin>>t;
    while(t--){
    solve();
  }
   debug("Total Time: %.3f\n", (double)(clock() - zzzz) / CLOCKS_PER_SEC);
      return 0;
}


#include<iostream>

using namespace std;

int main()
{
	int k;
	cin>>k;

	while(k>0)
	{
		int first_row = -1;
		int second_row;
		int first_col = -1;
		int second_col;

		for(int i=0;i<8;i++)
		{
			for(int j=0;j<8;j++)
			{
				char c;
				cin>>c;
				if(c=='K')
				{
					if(first_col==-1)
					{
						first_row = i;
						first_col = j;
					}
					else
					{
						second_col = j;
						second_row = i;
					}
				}
			}
		}

		int dif_row = second_row - first_row;
		int dif_col = second_col - first_col;

		if(dif_row<0)
			dif_row*=-1;

		if(dif_col<0)
			dif_col*=-1;

		int dif = dif_col +dif_row;
		if(dif%4==0)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

		k--;
	}

	return 0;
}


#include<iostream>

using namespace std;

int main()
{
	int k;
	cin>>k;

	while(k>0)
	{
		int first_row = -1;
		int second_row;
		int first_col = -1;
		int second_col;

		for(int i=0;i<8;i++)
		{
			for(int j=0;j<8;j++)
			{
				char c;
				cin>>c;
				if(c=='K')
				{
					if(first_col==-1)
					{
						first_row = i;
						first_col = j;
					}
					else
					{
						second_col = j;
						second_row = i;
					}
				}
			}
		}

		int dif_row = second_row - first_row;
		int dif_col = second_col - first_col;

		if(dif_row<0)
			dif_row*=-1;

		if(dif_col<0)
			dif_col*=-1;

		int dif = dif_col +dif_row;
		if(dif%8==0)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

		k--;
	}

	return 0;
}


#include<iostream>

using namespace std;

int main()
{
	int k;
	cin>>k;

	while(k>0)
	{
		int first_row = -1;
		int second_row;
		int first_col = -1;
		int second_col;

		for(int i=0;i<8;i++)
		{
			for(int j=0;j<8;j++)
			{
				char c;
				cin>>c;
				if(c=='K')
				{
					if(first_col==-1)
					{
						first_row = i;
						first_col = j;
					}
					else
					{
						second_col = j;
						second_row = i;
					}
				}
			}
		}

		int dif_row = second_row - first_row;
		int dif_col = second_col - first_col;

		if(dif_row<0)
			dif_row*=-1;

		if(dif_col<0)
			dif_col*=-1;

		if(dif_col%4==0 && dif_row%4==0)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

		k--;
	}

	return 0;
}


#include<iostream>

using namespace std;

int main()
{
	int k;
	cin>>k;

	while(k>0)
	{
		int first_row = -1;
		int second_row;
		int first_col = -1;
		int second_col;

		for(int i=0;i<8;i++)
		{
			for(int j=0;j<8;j++)
			{
				char c;
				cin>>c;
				if(c=='K')
				{
					if(first_col==-1)
					{
						first_row = i;
						first_col = j;
					}
					else
					{
						second_col = j;
						second_row = i;
					}
				}
			}
		}

		int dif_row = second_row - first_row;
		int dif_col = second_col - first_col;

		if(dif_row<0)
			dif_row*=-1;

		if(dif_col<0)
			dif_col*=-1;

		int dif = dif_col +dif_row;
		if(dif_col%4==0 && dif_row%4==0)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}

		k--;
	}

	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const ld PI = acos(-1)/180;

/*class cmp {
    public:
        bool operator()(pair<int , int> a ,pair<int , int> b){
            return a.second < b.second;
        }
};*/

int main()
{
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t , c1 , c2 , c3 , c4;
    string s[8];
    vector <int> v;
    cin>>t;

    while (t--){
        v.clear();

        for(int i = 0 ; i < 8 ; i++){
            cin>>s[i];
        }

        for(int i = 0 ; i<8 && (int)v.size()<4 ; i++){
            for(int j = 0 ; j<8 && (int)v.size()<4 ; j++){
                if (s[i][j] == 'K'){
                    v.push_back(i);
                    v.push_back(j);
                }
            }
        }

        //for(int a:v)
        //    cout<<a<<endl;

        int k;
        for(k = 0 ; k<8 ; k++){
            int l;
            for(l = 0 ; l<8 ; l++){
                c1 = abs(k - v[0]);
                c2 = abs(l - v[1]);
                c3 = abs(k - v[2]);
                c4 = abs(l - v[3]);
                if ((s[k][l] != '#') && (!(c1 & 1)) && (!((c1 + c2)%4))){
                    if ((!(c3 & 1)) && (!((c3 + c4)%4)) && max(c1 , c2) == max(c3 , c4)){
                        cout<<"YES"<<endl;
                        break;
                    }
                }
            }
            if (l<8)
                break;
        }
        if (k == 8)
            cout<<"NO"<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const ld PI = acos(-1)/180;

/*class cmp {
    public:
        bool operator()(pair<int , int> a ,pair<int , int> b){
            return a.second < b.second;
        }
};*/

int main()
{
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    string s[8];
    vector <int> v;
    cin>>t;

    while (t--){
        v.clear();

        for(int i = 0 ; i < 8 ; i++){
            cin>>s[i];
        }

        for(int i = 0 ; i<8 && (int)v.size()<4 ; i++){
            for(int j = 0 ; j<8 && (int)v.size()<4 ; j++){
                if (s[i][j] == 'K'){
                    v.push_back(i);
                    v.push_back(j);
                }
            }
        }

        int k;
        for(k = 0 ; k<8 ; k++){
            int l;
            for(l = 0 ; l<8 ; l++){
                if ((s[k][l] == '.') && (!(abs(k - v[0]) & 1)) && (!((abs(k - v[0]) + abs(l-v[1]))%4))){
                    if ((!(abs(k - v[2]) & 1)) && (!((abs(k - v[2]) + abs(l-v[3]))%4))){
                        cout<<"YES"<<endl;
                        break;
                    }
                }
            }
            if (l<8)
                break;
        }
        if (k == 8)
            cout<<"NO"<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const ld PI = acos(-1)/180;

/*class cmp {
    public:
        bool operator()(pair<int , int> a ,pair<int , int> b){
            return a.second < b.second;
        }
};*/

int main()
{
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t , c1 , c2 , c3 , c4;
    string s[8];
    vector <int> v;
    cin>>t;

    while (t--){
        v.clear();

        for(int i = 0 ; i < 8 ; i++){
            cin>>s[i];
        }

        for(int i = 0 ; i<8 && (int)v.size()<4 ; i++){
            for(int j = 0 ; j<8 && (int)v.size()<4 ; j++){
                if (s[i][j] == 'K'){
                    v.push_back(i);
                    v.push_back(j);
                }
            }
        }

        //for(int a:v)
        //    cout<<a<<endl;

        int k;
        for(k = 0 ; k<8 ; k++){
            int l;
            for(l = 0 ; l<8 ; l++){
                c1 = abs(k - v[0]);
                c2 = abs(l - v[1]);
                c3 = abs(k - v[2]);
                c4 = abs(l - v[3]);
                if ((!(c1 & 1)) && (!((c1 + c2)%4))){
                    if ((!(c3 & 1)) && (!((c3 + c4)%4)) && max(c1 , c2) == max(c3 , c4)){
                        cout<<"YES"<<endl;
                        break;
                    }
                }
            }
            if (l<8)
                break;
        }
        if (k == 8)
            cout<<"NO"<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const ld PI = acos(-1)/180;

/*class cmp {
    public:
        bool operator()(pair<int , int> a ,pair<int , int> b){
            return a.second < b.second;
        }
};*/

int main()
{
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    string s[8];
    vector <int> v;
    cin>>t;

    while (t--){
        v.clear();

        for(int i = 0 ; i < 8 ; i++){
            cin>>s[i];
        }

        for(int i = 0 ; i<8 && (int)v.size()<4 ; i++){
            for(int j = 0 ; j<8 && (int)v.size()<4 ; j++){
                if (s[i][j] == 'K'){
                    v.push_back(i);
                    v.push_back(j);
                }
            }
        }

        //for(int a:v)
        //    cout<<a<<endl;

        int k;
        for(k = 0 ; k<8 ; k++){
            int l;
            for(l = 0 ; l<8 ; l++){
                if ((s[k][l] != '#') && (!(abs(k - v[0]) & 1)) && (!((abs(k - v[0]) + abs(l-v[1]))%4))){
                    if ((!(abs(k - v[2]) & 1)) && (!((abs(k - v[2]) + abs(l-v[3]))%4))){
                        cout<<"YES"<<endl;
                        break;
                    }
                }
            }
            if (l<8)
                break;
        }
        if (k == 8)
            cout<<"NO"<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#include <fstream>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

double Fib(double x,double z);
string BinDec(ull x);
string StringInt(ll x);
ull StringInt(string x);
ull BinDec (string x);
ull POWMOD (ull x,ull y,ull mod);
ull POWE(long long , long long);

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;
    while(n--)
    {
        char x[14][14]={};
        int e=0,i,j,c[14][14]={},l[14][14]={},d[14][14]={};
        for(i=4;i<8+4;i++)
            for(j=4;j<8+4;j++)
            {
                cin>>x[i][j];
                if(x[i][j]=='#')c[i][j]=-1;
                if(x[i][j]=='K'&&e==0)
                {
                    e=1;
                    d[i][j]=1;
                    d[i][j]=-1;
                    d[i+2][j+2]=d[i+2][j-2]=d[i-2][j+2]=d[i-2][j-2]=1;
                }
                else if(x[i][j]=='K')
                {
                    l[i][j]=1;
                    l[i][j]=-1;
                    l[i+2][j+2]=l[i+2][j-2]=l[i-2][j+2]=l[i-2][j-2]=1;
                }
            }

        bool ans=0;
        for(i=4;i<8+4;i++)
        {
            for(j=4;j<8+4;j++)
            {
                if(l[i][j]==1||l[i][j]==-1)
                {
                    if(d[i][j]==1||d[i][j]==-1)
                    {
                            ans=1;
                    }
                }
            }
        }
        if(ans)cout<<"YES";
        else cout<<"NO";

        cout<<'\n';
    }

    return 0;
}

double Fib(double x,double z){
    int i=0;
    double f=x,r=x,t;
    for(i=2;i<z;i++)
    {
        t=f;
        f+=r;
        r=t;
    }
    return f;

}
string BinDec( ull x){
    string z;
    while(1)
    {
        z+=((x%3)+'0');
        x/=3;
        if(x==0)
            break;
    }
    while(1)
    {
        if(z.size()==30)
            break;
        z+='0';
    }
    reverse(z.begin(),z.end());
    return z;
}
ull BinDec(string x){
    long long i;
    unsigned long long z=1,a=0;
    for(i=x.size()-1;i>=0;i--)
    {
        if(x[i]=='1')
            a+=z;
        if(x[i]=='2')
            a+=(2*z);
        z*=3;
    }
    return a;
}
ull StringInt(string x){
   ull z=0,i;
   for(i=0;i<x.size();i++)
   {
       z*=2;
       z+=(x[i]-'0');
   }
   return z;
}
string StringInt(ll x){
    string z;
    while(x!=0)
    {
        z+=(x%10+'0');
        x/=10;
    }
    reverse(z.begin(),z.end());
    return z;
}
ull POWMOD (ull base,ull exp,ull mod){
    ull res=1;
    while(exp>0){
        if(exp%2==1)
            res=(res*base);
            res%=mod;
        exp/=2;
        base=(base*base);
        base%=mod;
    }
return res%mod;
}
ull POWE(long long base,long long exp){
    ull res=1;
    while(exp>0){
        if(exp%2==1)
            res=(res*base);
        exp/=2;
        base=(base*base);
    }
return res;

}

/*
int s=0,c[1553][1553]={},z;
char a[1550][1550]={};
void lol(char m,int i,int j,int & s)
{

    if(c[i][j+1]==0&&a[i][j+1]==m)
    {
        s++;
        c[i][j+1]=1;
        lol(m,i,j+1,s);
    }
    if(c[i][j-1]==0&&a[i][j-1]==m)
    {
        s++;
        c[i][j-1]=1;
        lol(m,i,j-1,s);
    }
    if(c[i-1][j]==0&&a[i-1][j]==m)
    {
        s++;
        c[i-1][j]=1;
        lol(m,i-1,j,s);
    }
    if(c[i+1][j]==0&&a[i+1][j]==m)
    {
        s++;
        c[i+1][j]=1;
        lol(m,i+1,j,s);
    }
    if(z!=0)
    {
        z--;
        a[i][j]='X';
    }
    return;
}*/