# Codeforces Beta Round #14 (Div. 2)A. Letter

A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.

Input

The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.

Output

Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.

Examples

input

Copy

```6 7
.......
..***..
..*....
..***..
..*....
..***..```

output

Copy

```***
*..
***
*..
***```

input

Copy

```3 3
***
*.*
***```

output

Copy

```***
*.*
***```

```// luogu-judger-enable-o2
#include<bits/stdc++.h>
#include<unordered_set>
#define rg register ll
#define inf 2147483647
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define ll long long
#define maxn 55
const double eps = 1e-6;
using namespace std;
{
char ch = getchar(); ll s = 0, w = 1;
while (ch < 48 || ch>57) { if (ch == '-')w = -1; ch = getchar(); }
while (ch >= 48 && ch <= 57) { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); }
return s * w;
}
inline void write(ll x)
{
if (x < 0)putchar('-'), x = -x;
if (x > 9)write(x / 10);
putchar(x % 10 + 48);
}
ll n,m;
char s[maxn][maxn];
int main()
{
cin>>n>>m;
ll hmax=-inf,lmax=-inf,hmin=inf,lmin=inf;
for(rg i=1;i<=n;i++)
{
for(rg j=1;j<=m;j++)
{
cin>>s[i][j];
if(s[i][j]=='*')
{
hmax=max(hmax,i);
lmax=max(lmax,j);
lmin=min(lmin,j);
hmin=min(hmin,i);
}
}
}
for(rg i=hmin;i<=hmax;i++)
{
for(rg j=lmin;j<=lmax;j++)
{
cout<<s[i][j];
}cout<<endl;
}
return 0;
}```

0 条评论

• ### 2018-2019 ICPC, NEERC, Southern Subregional Contest D. Garbage Disposal

Enough is enough. Too many times it happened that Vasya forgot to dispose of gar...

• ### Codeforces Round #622 (Div. 2) A.Fast Food Restaurant

Tired of boring office work, Denis decided to open a fast food restaurant.

• ### Codeforces Round #615 (Div. 3) F. Three Paths on a Tree

You are given an unweighted tree with nn vertices. Recall that a tree is a conne...

• ### uva-----11292 The Dragon of Loowater

Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, ...

• ### UVA 11292 Dragon of Loowater(简单贪心)

Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, ...

• ### spark 2.3 导致driver OOM的一个SparkPlanGraphWrapper源码的bug

长话短说，我们部门一个同事找到我，说他的spark 2.3 structured streaming程序频繁报OOM，从来没有坚持过超过三四天的，叫帮看一下。 ...

• ### 医学图像分割--Segmentation of Medical Ultrasound Images...

版权声明：本文为博主原创文章，未经博主允许不得转载。 https://blog.csdn.net/zhangjunhit/article/de...

• ### HDU 1019 Least Common Multiple【gcd+lcm+水+多个数的lcm】

Least Common Multiple Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65...

• ### 史上最全的vim快捷键文档/手册/大全/帮助/指南

Tip Run vimtutor in a terminal to learn the first Vim commands.