B - Almost Rectangle

 1. Problem

There is a square field of size n \times nn×n in which two cells are marked. These cells can be in the same row or column.

You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.

For example, if n=4n=4 and a rectangular field looks like this (there are asterisks in the marked cells):

\begin{matrix} . & . & * & . \\ . & . & . & . \\ * & . & . & . \\ . & . & . & . \\ \end{matrix}..∗.​....​∗...​....​

Then you can mark two more cells as follows

\begin{matrix} * & . & * & . \\ . & . & . & . \\ * & . & * & . \\ . & . & . & . \\ \end{matrix}∗.∗.​....​∗.∗.​....​

If there are several possible solutions, then print any of them.

Input

The first line contains a single integer tt (1 \le t \le 4001≤t≤400). Then tt test cases follow.

The first row of each test case contains a single integer nn (2 \le n \le 4002≤n≤400) — the number of rows and columns in the table.

The following nn lines each contain nn characters '.' or '*' denoting empty and marked cells, respectively.

It is guaranteed that the sums of nn for all test cases do not exceed 400400.

It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.

It is guaranteed that the solution exists.

Output

For each test case, output nn rows of nn characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.

Example

input

6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...

output

*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..

2. Accepted Code

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

string s[407];

int main()
{
	int t;
	cin >> t;
	int i, j;

	while (t--)
	{
		int n;
		cin >> n;
		for (i = 0; i < n; i++)
		{
			cin >> s[i];
		}
		int x1, y1, x2, y2, flag = 0;
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				if (s[i][j] == '*')
				{
					if (!flag)
					{
					    //记录第一个星号位置
						x1 = i;
						y1 = j;
						flag = 1;
					}
					else
					{
					    //记录第二个星号位置
						x2 = i;
						y2 = j;
					}
				}
			}
		}
		if (x1 == x2)
		{
		    //如果两个星号在同一行
			if (x1 == 0)
			{
				x1 = 1;
				x2 = 1;
			}
			else
			{
				x1 = 0;
				x2 = 0;
			}
		}
		else if (y1 == y2)
		{
		    //如果两个星号在同一列
			if (y1 == 0)
			{
				y1 = 1;
				y2 = 1;
			}
			else
			{
				y1 = 0;
				y2 = 0;
			}
		}
		s[x1][y2] = '*';
		s[x2][y1] = '*';
		for (i = 0; i < n; i++)
		{
			cout << s[i] << '\n';
		}
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值