/**************
Header Files
**************/
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <stdexcept>
#include <string>
#include <iomanip>
using namespace std;
typedef vector<int> vi;
int main()
{
int row,col;
cin>>row>>col;
const int cols=col;
const int rows=row;
char Array[rows][cols];
string sentence;
vi A;
vi B;
for(int i=0;i<rows;i++)
{ cin>>sentence;
for (int j=0;j<cols;j++)
{ Array[i][j]=sentence[j];
if (Array[i][j]=='*')
{ A.push_back(i);
B.push_back(j); }
}
}
for(int i=A.at(0);i<A.at(A.size());i++)
{
int max_B=0;
int min_B=row-1;
for ( unsigned l=0;l<B.size();l++)
{
if(max_B < B.at(l))
max_B=B.at(l);
if(min_B > B.at(l))
min_B=B.at(l);
}
for (int j=min_B;j<max_B;j++)
{ cout<<Array[i][j];
}
}
cin.get();
cin.ignore();
return 0;
}
Header Files
**************/
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <stdexcept>
#include <string>
#include <iomanip>
using namespace std;
typedef vector<int> vi;
int main()
{
int row,col;
cin>>row>>col;
const int cols=col;
const int rows=row;
char Array[rows][cols];
string sentence;
vi A;
vi B;
for(int i=0;i<rows;i++)
{ cin>>sentence;
for (int j=0;j<cols;j++)
{ Array[i][j]=sentence[j];
if (Array[i][j]=='*')
{ A.push_back(i);
B.push_back(j); }
}
}
for(int i=A.at(0);i<A.at(A.size());i++)
{
int max_B=0;
int min_B=row-1;
for ( unsigned l=0;l<B.size();l++)
{
if(max_B < B.at(l))
max_B=B.at(l);
if(min_B > B.at(l))
min_B=B.at(l);
}
for (int j=min_B;j<max_B;j++)
{ cout<<Array[i][j];
}
}
cin.get();
cin.ignore();
return 0;
}