#define CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ordered_set tree<pair<ll,ll>, null_type, less <pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define all(name)  name.begin(),name.end()
#define rall(name)  name.rbegin(),name.rend()
#define sz(s) (int)s.size()
const int N = 2e6 + 10, mod = 1e9 + 7;
const double PI = asin(1.0) * 2;
const int OO = 0x3f3f3f3f;
int dx[]{1, -1, 0, 0, 1, 1, -1, -1};
int dy[]{0, 0, 1, -1, 1, -1, 1, -1};

void fast() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

map<string, bool> mp;

bool isWin(string s) {
    return (
            // row
            (s[0] != '.' && s[0] == s[1] && s[0] == s[2]) ||
            (s[3] != '.' && s[3] == s[4] && s[3] == s[5]) ||
            (s[6] != '.' && s[6] == s[7] && s[6] == s[8]) ||
            // col
            (s[0] != '.' && s[0] == s[3] && s[0] == s[6]) ||
            (s[1] != '.' && s[1] == s[4] && s[1] == s[7]) ||
            (s[2] != '.' && s[2] == s[5] && s[2] == s[8]) ||
            // diag
            (s[0] != '.' && s[0] == s[4] && s[0] == s[8]) ||
            (s[0] != '.' && s[2] == s[4] && s[2] == s[6])
    );
}

string ans;
bool ck = 0;

void bfs(string s = ".........") {
    ck = 0;
    queue<pair<string, bool>> q; // grid, player( X --> 1, O --> 0)
    q.push({s, 1});
    while (!q.empty()) {
        pair<string, bool> p = q.front();
        q.pop();
        string grid = p.first;
        if (grid == ans) {
            ck = 1;
            break;
        }
        if (!isWin(grid)) {
            for (int i = 0; i < 9; i++) {
                if (grid[i] == '.') {
                    if (p.second) grid[i] = 'X'; else grid[i] = 'O';
                    if (grid[i] == ans[i])
                        q.push({grid, p.second ^ 1});
                    grid[i] = '.';
                }
            }
        }
    }
}

void solve() {
    string s;
    ans = "";
    for (int i = 0; i < 3; i++) {
        cin >> s;
        ans += s;
    }
    bfs();
    cout << (ck ? "yes" : "no") << "\n";
}

int main() {
    fast();
    //freopen("abc.in", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}