#include <iostream>

using namespace std;

int t, n ;

int main()
{

    cin >> t ;

    for (int k = 1 ; k <= t ; k ++)
    {

        cin >> n ;

        char v[405][405] = {0} ;
        int x1 = 0, x2 = 0, y1 = 0, y2 = 0 ;

        for (int i = 1 ; i <= n ; i ++)
            for (int j = 1 ; j <= n ; j ++)
            {

                cin >> v[i][j] ;

                if (v[i][j] == '*' && x1 == 0 && y1 == 0)
                    x1 = i, y1 = j ;

                else if (v[i][j] == '*' && x1 != 0 && y1 != 0)
                    x2 = i, y2 = j ;

            }

        if (x1 != x2 && y1 != y2)
            v[x1][y2] = v[x2][y1] = '*' ;

        if (x1 == x2 && y1 != y2)
        {



            if (x1 == 1)
                v[x1 + 1][y2] = v[x2 + 1][y1] = '*' ;

            else if (x1 == n)
                v[x1 - 1][y2] = v[x2 - 1][y1] = '*' ;

            else
                v[x1 + 1][y1] = v[x2 + 1][y2] = '*' ;

        }

        if (x1 != x2 && y1 == y2)
        {

            if (y1 == 1)
                v[x1][y1 + 1] = v[x2][y2 + 1] = '*' ;

            else if (y1 == n)
                v[x1][y1 - 1] = v[x2][y2 - 1] = '*' ;

            else
                v[x1][y1 + 1] = v[x2][y2 + 1] = '*' ;


        }

        for (int i = 1 ; i <= n ; i ++)
        {

            for (int j = 1 ; j <= n ; j ++)
                cout << v[i][j] ;
            cout << '\n' ;

        }

    }

    return 0 ;

}
