read h w;
a=(`grep '#'`);
for((j=0;j<w;j++))do
	f=0;
	for((k=0;k<${#a[@]};k++))do
		if [ ${a[$k]:$j:1} = "#" ];then
			f=1;
		fi
	done
	b=( "${b[@]}" $f );
done
for((i=0;i<${#a[@]};i++))do
	for((j=0;j<w;j++))do
		if [ ${b[$j]} -eq 1 ];then
			echo -n ${a[$i]:$j:1}
		fi
	done
	echo ''
done
