#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair <int, int>
#define ld long double
#define ins insert
#define pb push_back
using namespace std;

const int N = 2e5 + 5;
const ll inf = 1e13;

std::vector<std::vector<int>> getVisionPattern2d()
{
    return {{2, 1, 2, 1, 1}, {1, 1, 1, 1, 1}, {2, 1, 3, 1, 2}, {1, 1, 1, 1, 1}, {2, 1, 2, 1, 2}};
}
std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
    int n = v.size();
    if (n == 3)
    {
        for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) if (v[i][j] == 2) return {i, j};
        return {0, 0};
    }
    if (n == 5)
    {
        for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) if (v[i][j] == 3) return {i, j};
        return {0, 0};
    }
    if (n == 7)
    {
        if (v[1][1] == 1) return {0, 0};
        if (v[1][5] == 1) return {0, 6};
        if (v[5][1] == 1) return {6, 0};
        if (v[5][5] == 1) return {6, 6};
        return {1, 1};
    }
}

std::vector<int> getVisionPattern1d()
{
    return {1, 1, 1, 2, 1, 3};
}

int getMove1d(std::vector<int> v)
{
    int n = v.size();
    if (n == 3)
    {
        if (v[0] == 1 && v[2] == 1) return 0;
        if (v[0] != 1) return 0;
        return 2;
    }
    if (n == 5)
    {
        if (v[0] == 3) return 0;
        return 4;
    }
    if (n == 7)
    {
        if (v[1] == 2) return 6;
        return 0;
    }
}

//int32_t main()
//{
//    int t;
//    cin >> t;
//    while (t--)
//    {
//        int n;
//        cin >> n;
//        vector <int> a;
//        for (int i = 1; i <= n; i++)
//        {
//            int v;
//            cin >> v;
//            a.pb(v);
//        }
//        vector <int> ans = solve(a);
//        for (auto to: ans) cout << to << ' ';
//        cout << endl;
//
//    }
//    return 0;
//}
