#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;
bool good(string &s){
	bool notspace = 0;
	for(int i =0 ;i < (int)s.size(); i++){
		if(s[i] == '#' && !notspace) return 1;
		notspace |= s[i] != ' ';
	}
	return 0;
}
string get(vector<string>& input){
	string ret = "";
	int n = input.size();
	for(int i = 0; i< n ;i++){
		string &curr = input[i];
		if(good(curr)) ret+= (ret.size() ? "\n" : "") + curr+"\n";
		else{
			for(char c : curr){
				if(c != ' ') ret += c;
			}
		}
	}
	return ret;
}
int main()
{
   // IO;
	vector<string> arr;
	string s;
	getline(cin, s);
	int z = 1048576;
	while(z--){
		arr.pb(s);
		getline(cin, s);
		//cout<<(int)s[0]<<"\n";
	}
	string ans = get(arr);
	if(ans[ans.size()-1] != '\n') ans += "\n";
	cout<<get(arr);
	//for(string x : arr) cout<<x<<"\n";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;
bool good(string &s){
	bool notspace = 0;
	for(int i =0 ;i < (int)s.size(); i++){
		if(s[i] == '#' && !notspace) return 1;
		notspace |= s[i] != ' ';
	}
	return 0;
}
string get(vector<string>& input){
	string ret = "";
	int n = input.size();
	for(int i = 0; i< n ;i++){
		string &curr = input[i];
		if(good(curr)) ret+= (ret.size() ? "\n" : "") + curr+"\n";
		else{
			for(char c : curr){
				if(c != ' ') ret += c;
			}
		}
	}
	return ret;
}
int main()
{
   // IO;
	vector<string> arr;
	string s;
	while(getline(cin,s)){
		arr.pb(s);
	}
	string ans = get(arr);
	if(ans[ans.size()-1] != '\n') ans += "\n";
	cout<<get(arr);
	//for(string x : arr) cout<<x<<"\n";

	return 0;
}


// A Level UP!
//This period is tough and shall pass!!
//Virtual Round
#include <bits/stdc++.h>
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define int long long int
using namespace std;
int32_t main()
{
    SKY;
    string s;
    int done=0;
    while(getline(cin,s))
    {
        int curr=0;
        for(auto it: s)
        {
            curr++;
            if(it==' ')
            {
                break;
            }
        }
        if(curr==s.size() or s[curr]!='#')
        {
            if(done==2)
                cout<<"\n";
            for(auto it: s)
                if(it!=' ')
                    cout<<it;
            done=1;
        }
        else{
            if(done)
                cout<<"\n";
            cout<<s;
            done=2;
        }
    }
    return 0;
}


// A Level UP!
//This period is tough and shall pass!!
//Virtual Round
#include <bits/stdc++.h>
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lp(i,start,end) for(int i=start;i<end;i++)
#define MAX 105
#define int long long int
using namespace std;
int32_t main()
{
    SKY;
    string s;
    int done=0;
    while(getline(cin,s))
    {
        int i=0;
        for(i=0;i<s.size();i++)
        {
            if(s[i]!=' ')
            {
                break;
            }
        }
        if(i==s.size() or s[i]!='#')
        {
            if(done==2)
                cout<<"\n";
            for(auto it: s)
                if(it!=' ')
                    cout<<it;
            done=1;
        }
        else{
            if(done)
                cout<<"\n";
            cout<<s;
            done=2;
        }
    }
    cout<<"\n";
    return 0;
}


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

char s[1234567], qq[1234567];
int qn, have;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int i, j, k, n;
  while (gets(s) != NULL)
  {
    for (i = 0; s[i] == ' '; i++)
      ;
    if (s[i] == '#')
    {
      if (have)
      {
        qq[qn] = 0;
        puts(qq);
        have = 0;
      }
      puts(s);
      qn = 0;
    }
    else
    {
      have = 1;
      for (i = 0; s[i]; i++)
      {
        if (s[i] != ' ')
          qq[qn++] = s[i];
      }
    }
  }
  if (have)
  {
    qq[qn] = 0;
    puts(qq);
  }
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
  return '"' + s + '"';
}

string to_string(const char *s)
{
  return to_string((string)s);
}

string to_string(bool b)
{
  return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
  string res = "";
  for (size_t i = 0; i < N; i++)
  {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string line;
  bool prev_amp = true;
  while (getline(cin, line))
  {
    debug(line);
    bool is_amp = false;
    for (int i = 0; i < line.length(); ++i)
    {
      if (line[i] != ' ')
      {
        if (line[i] == '#')
          is_amp = true;
        else
          is_amp = false;
        break;
      }
    }
    if (is_amp)
    {
      if (!prev_amp)
        cout << endl;
      cout << line;
    }
    else
    {
      if (prev_amp)
        cout << endl;
      for (int i = 0; line[i]; ++i)
      {
        if (line[i] != ' ' && line[i] != '\n')
          cout << line[i];
      }
    }
    prev_amp = is_amp;
  }
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
  return '"' + s + '"';
}

string to_string(const char *s)
{
  return to_string((string)s);
}

string to_string(bool b)
{
  return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
  string res = "";
  for (size_t i = 0; i < N; i++)
  {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string line;
  bool prev_amp = true;
  while (getline(cin, line))
  {
    debug(line);
    bool is_amp = false;
    for (int i = 0; i < line.length(); ++i)
    {
      if (line[i] != ' ')
      {
        if (line[i] == '#')
          is_amp = true;
        else
          is_amp = false;
        break;
      }
    }
    if (is_amp)
    {
      if (!prev_amp)
        cout << '\n';
      cout << line << '\n';
    }
    else
    {
      for (int i = 0; line[i]; ++i)
      {
        if (line[i] != ' ' && line[i] != '\n')
          cout << line[i];
      }
    }
    prev_amp = is_amp;
  }
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
  return '"' + s + '"';
}

string to_string(const char *s)
{
  return to_string((string)s);
}

string to_string(bool b)
{
  return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
  string res = "";
  for (size_t i = 0; i < N; i++)
  {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string line;
  bool prev_amp = true;
  while (getline(cin, line))
  {
    debug(line);
    bool is_amp = false;
    for (int i = 0; i < line.length(); ++i)
    {
      if (line[i] != ' ')
      {
        if (line[i] == '#')
          is_amp = true;
        else
          is_amp = false;
        break;
      }
    }
    if (is_amp)
    {
      if (!prev_amp)
        cout << endl;
      cout << line;
    }
    else
    {
      if (prev_amp)
        cout << endl;
      for (int i = 0; line[i]; ++i)
      {
        if (line[i] != ' ' && line[i] != '\n')
          cout << line[i];
      }
    }
    prev_amp = is_amp;
  }
  cout << endl;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
  return '"' + s + '"';
}

string to_string(const char *s)
{
  return to_string((string)s);
}

string to_string(bool b)
{
  return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
  string res = "";
  for (size_t i = 0; i < N; i++)
  {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v)
{
  bool first = true;
  string res = "{";
  for (const auto &x : v)
  {
    if (!first)
    {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string line;
  bool prev_amp = true;
  while (getline(cin, line))
  {
    debug(line);
    bool is_amp = false;
    for (int i = 0; i < line.length(); ++i)
    {
      if (line[i] != ' ')
      {
        if (line[i] == '#')
          is_amp = true;
        else
          is_amp = false;
        break;
      }
    }
    if (is_amp)
    {
      if (!prev_amp)
        cout << '\n';
      cout << line;
    }
    else
    {
      if (prev_amp)
        cout << '\n';
      for (int i = 0; line[i]; ++i)
      {
        if (line[i] != ' ' && line[i] != '\n')
          cout << line[i];
      }
    }
    prev_amp = is_amp;
  }
}


#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll lcm(ll x, ll y)
{
    return (x*y)/__gcd(x,y);
}
char a[1048580],b[1048580];
bool l=0;
int main()
{
  //  mego
    int id=0;
   while(gets(a))
   {
       int idx=0;
       while(a[idx]==' ')idx++;
       if(a[idx]=='#')
       {
           if(l)
           {b[id]=0;
            puts(b);
            l=0;
           }

          puts(a); id=0;

       }
       else {
            l=1;//empty lines
        idx=0;
        while(a[idx])
        {if(a[idx]!=' ')b[id++]=a[idx];
        idx++;
        }
       }

   }
cout<<"\nmm\n";
   if(l)b[id]=0,puts(b);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll lcm(ll x, ll y)
{
    return (x*y)/__gcd(x,y);
}
char a[1048580],b[1048580];
bool l=0;
int main()
{
  //  mego
    int id=0;
   while(gets(a))
   {
       int idx=0;
       while(a[idx]==' ')idx++;
       if(a[idx]=='#')
       {
           if(l)
           {b[id]=0;
            puts(b);
            l=0;
           }

          puts(a); id=0;

       }
       else {
            l=1;//empty lines
        idx=0;
        while(a[idx])
        {if(a[idx]!=' ')b[id++]=a[idx];
        idx++;
        }
       }

   }
//cout<<"\nmm\n";
   if(l)b[id]=0,puts(b);
    return 0;
}


// clang-format off
#define protected public
using iii  = int;
using yeee = iii;
#ifdef LOCAL
    const iii DEBUG = 10;
#else
    const iii DEBUG = -1;
#endif
#include <bits/stdc++.h>
using namespace std;
#if 0
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace __gnu_pbds; template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T, class U> using hash_map = gp_hash_table<T, U>;
#endif
#define DBG(x) if(DEBUG >= x)
#define FOR(i, lo, hi) for(ll i = ll(lo); i < ll(hi); ++i)
#define ROF(i, hi, lo) for(ll i = ll(hi); i >= (ll)(lo); --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ll((x).size())
#define pb push_back
#define apply(f, x, y) (x) = f((x), (y))
using ll = long long; using ull = unsigned long long; using ld = long double; using pll = pair<ll, ll>; using vb = vector<bool>; using vvb = vector<vb>; using vll = vector<ll>; using vvll = vector<vll>; using vpll = vector<pll>; using point = complex<ll>; /*|||*/ template <template <typename...> class Container, typename T, size_t DIMENSION> struct MultiDimensional { using internal = MultiDimensional<Container, T, DIMENSION - 1>; using type = Container<typename internal::type>; template <typename... Args> static type Generate(T def, const size_t size, Args... sizes) { return type(size, internal::Generate(def, sizes...)); } }; template <template <typename...> class Container, typename T> struct MultiDimensional<Container, T, 1> { using internal = T; using type = Container<T>; static type Generate(T def, const size_t size) { return type(size, def); } }; template <typename T, typename... Args> auto make_vector(T def, Args... sizes) -> typename MultiDimensional<std::vector, T, sizeof...(sizes)>::type { return MultiDimensional<std::vector, T, sizeof...(sizes)>::Generate( def, sizes...); } /*|||*/ template <class T> T get() { T x; cin >> x; return x; } template <class T1, class T2> ostream &operator<<(ostream &out, const pair<T1, T2> &cont) { out << "(" << cont.first << ", " << cont.second << ")"; return out; } template <class T> ostream &operator<<(ostream &out, const vector<T> &cont) { for(long long int i = 0; i < (long long int)(cont.size()); ++i) out << (i ? " " : "") << cont[i]; return out; } template <class T> ostream &operator<<(ostream &out, const set<T> &cont) { out << "{"; for(const T &x : cont) out << x << ", "; out << "}"; return out; } template <class T, class U> ostream &operator<<(ostream &out, const map<T, U> &cont) { out << "{"; for(const pair<T, U> &x : cont) out << "(" << x.first << ": " << x.second << "), "; out << "}"; return out; } template <class T> ostream &operator<<(ostream &out, vector<vector<T>> &cont) { for(vector<T> &v : cont) { for(long long int i = 0; i < (long long int)(v.size()); ++i) { out << (i ? " " : "") << v[i]; } out << " "; } return out; } /*|||*/ using time_type = std::chrono::_V2::system_clock::time_point; time_type get_time() { return chrono::high_resolution_clock::now(); } ld get_duration(time_type start_time, time_type end_time) { return ld(chrono::duration_cast<chrono::nanoseconds>(end_time - start_time) .count()) / 1e9; } /*|||*/ ll sign(ld x) { return (x > 0) - (x < 0); } ll pow(ll x, ll exp, ll mod) { ll res = 1, y = x; while(exp) { if(!mod) { if(exp & 1) res = res * y; y = y * y; } else { if(exp & 1) res = (res * y) % mod; y = (y * y) % mod; } exp >>= 1; } return res; } /*|||*/ time_type START_TIME = get_time(); mt19937_64 rand_mt64(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rand_mt(chrono::steady_clock::now().time_since_epoch().count()); const long long INFll = 3e18 - 1; const int INFi = 3e8 - 1; ll INF; char newl = '\n'; /*|||*/ void main_init(string input_file = "", string output_file = "", bool fast_cio = true) { if(fast_cio) { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } srand(unsigned(time(0))); DBG(0 && input_file != "") freopen(input_file.c_str(), "r", stdin); DBG(0 && output_file != "") freopen(output_file.c_str(), "w", stdout); if(sizeof(ll) == sizeof(int)) { INF = ll(INFi); } else { INF = ll(INFll); } }
// clang-format on

yeee main() {
    main_init();
    //

    string white = " \t\n";

    pair<bool, string> r = {false, ""};
    while(true) {
        string s;
        if(!getline(cin, s))
            break;

        bool prep = false;
        for(char c : s) {
            if(c == '#')
                prep = true;
            else if(white.find(c) != white.npos)
                continue;
            break;
        }

        if(prep) {
            if(r.first) {
                cout << r.second << newl;
                r = {false, ""};
            }
            cout << s << newl;
        } else {
            r.first = true;
            for(char c : s) {
                if(white.find(c) != white.npos)
                    continue;
                r.second.pb(c);
            }
        }
    }

    if(r.first)
        cout << r.second << newl;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	vs t;
	vi amp;
	while(getline(cin, s)){
		int yes = false;
		for(auto c: s){
			if(c == '#'){
				yes = true;
				break;
			}
			if(c != ' '){
				break;
			}
		}
		if(yes){
			t.push_back(s);
		}
		else{
			string temp;
			for(auto c: s){
				if(c != ' '){
					temp.push_back(c);
				}
			}
			t.push_back(temp);
		}
		amp.push_back(yes);
	}
	if(t.size()) cout << t[0];
	for(int i = 1; i < t.size(); i ++){
		if(!amp[i] && !amp[i - 1]){
			cout << t[i];
		}
		else{
			cout << "\n" << t[i];
		}
	}
	cout << "\n";
	return 0;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> tpl;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
mt19937 rnd(time(0));

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	vs t;
	vi amp;
	while(getline(cin, s)){
		int yes = false;
		for(auto c: s){
			if(c == '#'){
				yes = true;
				break;
			}
			if(c != ' '){
				break;
			}
		}
		if(yes){
			t.push_back(s);
		}
		else{
			string temp;
			for(auto c: s){
				if(c != ' '){
					temp.push_back(c);
				}
			}
			t.push_back(temp);
		}
		amp.push_back(yes);
	}
	if(t.size()) cout << t[0];
	for(int i = 1; i < t.size(); i ++){
		if(!amp[i] && !amp[i - 1]){
			cout << t[i];
		}
		else{
			cout << "\n" << t[i];
		}
	}
	return 0;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                                                                //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\                                    //
//           +++`+``+`+`++++        ///`````````````````````````````\\                              //
//           ++`+`+``+++`++++  /////```````````````````````````````````\                            //
//           +++`++`+`+``+++/////`````````````````````````````````````````\                         //
//             +++`++`+``+///```````````|```````````````````````````````````\                       //
//          ____++++/++++/`````````````/````````|````````|```````````````````\                      //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\                     //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\                   //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\                  //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\                 //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                //
//                                        Created by Aeren                                          //
//                                                                                //
//////////////////////////////////////////////////////////////////////////////////////////////////////


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

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

#define int long long
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
#define all(_v) _v.begin(), _v.end()
#define sz(a) ((int)a.size())
#define what_is(x) cout << #x << " is " << x << endl;
typedef long double ld;

const ll inf = 1e17 + 7;

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout.precision(10);

    string s;
    string new_s;

    bool s_have = false;

    while(cin) {
        getline (cin, new_s);
        int id = new_s.find_first_not_of(" ");
        if (id >= new_s.size() || new_s[id] != '#') {
            s_have = true;
            id = 0;
            while(true) {
                id = min(new_s.size(), new_s.find_first_not_of(" ", id));
                if (id == new_s.size()) break;

                int new_id =  min(new_s.size(), new_s.find_first_of(" ", id)) - 1;

                s += new_s.substr(id, new_id - id + 1);

                id = new_id + 1;
            }
        }else {
            if (s_have) cout << s << endl;

            s = "";
            s_have = false;

            cout << new_s << endl;
        }
    }

    if (s_have) cout << s;
}


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

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

#define int long long
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
#define all(_v) _v.begin(), _v.end()
#define sz(a) ((int)a.size())
#define what_is(x) cout << #x << " is " << x << endl;
typedef long double ld;

const ll inf = 1e17 + 7;

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout.precision(10);

    string s;
    string new_s;

    bool s_have = false;

    while(cin) {
        getline (cin, new_s);
        int id = new_s.find_first_not_of(" ");
        if (id >= new_s.size() || new_s[id] != '#') {
            s_have = true;
            id = 0;
            while(true) {
                id = min(new_s.size(), new_s.find_first_not_of(" ", id));
                if (id == new_s.size()) break;

                int new_id =  min(new_s.size(), new_s.find_first_of(" ", id)) - 1;

                s += new_s.substr(id, new_id - id + 1);

                id = new_id + 1;
            }
        }else {
            if (s_have) cout << s << endl;

            s = "";
            s_have = false;

            cout << new_s << endl;
        }
    }

    if (s_have) cout << s << endl;
}


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

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

#define int long long
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
#define all(_v) _v.begin(), _v.end()
#define sz(a) ((int)a.size())
#define what_is(x) cout << #x << " is " << x << endl;
typedef long double ld;

const ll inf = 1e17 + 7;

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout.precision(10);

    string s;
    string new_s;

    bool s_have = false;

    while(getline (cin, new_s)) {
        //cout << "what " << new_s << endl;

        int id = new_s.find_first_not_of(" ");
        if (id >= new_s.size() || new_s[id] != '#') {
            s_have = true;
            id = 0;
            while(true) {
                id = min(new_s.size(), new_s.find_first_not_of(" ", id));
                if (id == new_s.size()) break;

                int new_id =  min(new_s.size(), new_s.find_first_of(" ", id)) - 1;

                s += new_s.substr(id, new_id - id + 1);

                id = new_id + 1;
            }
        }else {
            if (s_have) cout << s << endl;

            s = "";
            s_have = false;

            cout << new_s << endl;
            //cout << "what" << endl;
        }
    }

    if (s_have) cout << s << endl;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <cmath>
#include <limits>
#include <list>
#include <memory>
#include <stack>
#include <iterator>
#include <queue>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cstring>
using namespace std;

#pragma GCC optimize("Ofast")
#define ll long long
#define ld long double
#define ull unsigned long long
#define V vector
#define pp pair<ll,ll>
#define pi 4*atan(1)
#define inf 1000000000000
#define max2(a,b) ((a<b)?b:a)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) ((a>b)?b:a)
#define min3(a,b,c) min2(min2(a,b),c)
#define what_is(x) cerr << #x << " is " << x << end
#define PS push_back
#define IT(x) begin(x),end(x)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define BOOLO(x) cout << (x ? "YES" : "NO") << endl
const int mod = 1e9 + 7;

void D(V<int> a) {
	for (int i : a)
		cout << i << " ";
	cout << endl;
}

bool isAmplifying(string s) {
	for (char i : s) {
		if (i != ' ') {
			return i == '#';
		}
	}
	return 0;
}

string removeSpace(string s) {
	string o = "";
	for (char i : s) {
		if (i != ' ') {
			o += i;
		}
	}
	return o;
}

void solve() { // ctrl z to end input
	V<string> s, o;
	string t;
	while (!cin.eof()) {
		getline(cin, t);
		s.PS(t);
	}
	t = "";
	bool p = 0;
	for (string i : s) {
		if (isAmplifying(i)) {
			if (p == 1) {
				o.PS(t);
				t = "";
			}
			o.PS(i);
		}
		else {
			t += removeSpace(i);
			p = 1;
		}
	}
	if (p == 1) {
		o.PS(t);
		t = "";
	}
	for (string i : o) {
		cout << i << endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	int t; cin >> t; while (t--)
		solve();
	return 0;
}

/**/


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <cmath>
#include <limits>
#include <list>
#include <memory>
#include <stack>
#include <iterator>
#include <queue>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cstring>
using namespace std;

#pragma GCC optimize("Ofast")
#define ll long long
#define ld long double
#define ull unsigned long long
#define V vector
#define pp pair<ll,ll>
#define pi 4*atan(1)
#define inf 1000000000000
#define max2(a,b) ((a<b)?b:a)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) ((a>b)?b:a)
#define min3(a,b,c) min2(min2(a,b),c)
#define what_is(x) cerr << #x << " is " << x << end
#define PS push_back
#define IT(x) begin(x),end(x)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define BOOLO(x) cout << (x ? "YES" : "NO") << endl
const int mod = 1e9 + 7;

void D(V<int> a) {
	for (int i : a)
		cout << i << " ";
	cout << endl;
}

bool isAmplifying(string s) {
	for (char i : s) {
		if (i != ' ') {
			return i == '#';
		}
	}
	return 0;
}

string removeSpace(string s) {
	string o = "";
	for (char i : s) {
		if (i != ' ') {
			o += i;
		}
	}
	return o;
}

void solve() { // ctrl z to end input
	V<string> s, o;
	string t;
	while (!cin.eof()) {
		getline(cin, t);
		s.PS(t);
	}
	t = "";
	bool p = 0;
//	cout << "got all - " << s.size() << endl;
	for (int i = 0; i < s.size() - 1; i++) {
		if (isAmplifying(s[i])) {
		//	cout << "amp - " << i << endl;
			if (p == 1) {
				cout << t << endl;
				t = "";
				p = 0;
			}
			cout << s[i] << endl;
		}
		else {
		//	cout << "remove space - " << i << endl;
			t += removeSpace(s[i]);
			p = 1;
		}
	//	cout << "pass - " << i << " = " << p << endl;
	}
	if (p == 1) {
	//	cout << "print last " << endl;
		cout << t << endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	int t; cin >> t; while (t--)
		solve();
	return 0;
}

/**/


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <cmath>
#include <limits>
#include <list>
#include <memory>
#include <stack>
#include <iterator>
#include <queue>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cstring>
using namespace std;

#pragma GCC optimize("Ofast")
#define ll long long
#define ld long double
#define ull unsigned long long
#define V vector
#define pp pair<ll,ll>
#define pi 4*atan(1)
#define inf 1000000000000
#define max2(a,b) ((a<b)?b:a)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) ((a>b)?b:a)
#define min3(a,b,c) min2(min2(a,b),c)
#define what_is(x) cerr << #x << " is " << x << end
#define PS push_back
#define IT(x) begin(x),end(x)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define BOOLO(x) cout << (x ? "YES" : "NO") << endl
const int mod = 1e9 + 7;

void D(V<int> a) {
	for (int i : a)
		cout << i << " ";
	cout << endl;
}

bool isAmplifying(string s) {
	for (char i : s) {
		if (i != ' ') {
			return i == '#';
		}
	}
	return 0;
}

string removeSpace(string s) {
	string o = "";
	for (char i : s) {
		if (i != ' ') {
			o += i;
		}
	}
	return o;
}

void solve() { // ctrl z to end input
	V<string> s, o;
	string t;
	while (!cin.eof()) {
		getline(cin, t);
		s.PS(t);
	}
	t = "";
	bool p = 0;
	for (string i : s) {
		if (isAmplifying(i)) {
			if (p == 1) {
				o.PS(t);
				t = "";
				p = 0;
			}
			o.PS(i);
		}
		else {
			t += removeSpace(i);
			p = 1;
		}
	}
	if (p == 1) {
		o.PS(t);
		t = "";
		p = 0;
	}
	for (string i : o) {
		cout << i << endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	int t; cin >> t; while (t--)
		solve();
	return 0;
}

/**/


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <cmath>
#include <limits>
#include <list>
#include <memory>
#include <stack>
#include <iterator>
#include <queue>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cstring>
using namespace std;

#pragma GCC optimize("Ofast")
#define ll long long
#define ld long double
#define ull unsigned long long
#define V vector
#define pp pair<ll,ll>
#define pi 4*atan(1)
#define inf 1000000000000
#define max2(a,b) ((a<b)?b:a)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) ((a>b)?b:a)
#define min3(a,b,c) min2(min2(a,b),c)
#define what_is(x) cerr << #x << " is " << x << end
#define PS push_back
#define IT(x) begin(x),end(x)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define BOOLO(x) cout << (x ? "YES" : "NO") << endl
const int mod = 1e9 + 7;

void D(V<int> a) {
	for (int i : a)
		cout << i << " ";
	cout << endl;
}

bool isAmplifying(string s) {
	for (char i : s) {
		if (i != ' ') {
			return i == '#';
		}
	}
	return 0;
}

string removeSpace(string s) {
	string o = "";
	for (char i : s) {
		if (i != ' ') {
			o += i;
		}
	}
	return o;
}

void solve() { // ctrl z to end input
	V<string> s, o;
	string t;
	while (!cin.eof()) {
		getline(cin, t);
		s.PS(t);
	}
	t = "";
	bool p = 0;
	for (int i = 0; i < s.size() - 1; i++) {
		if (isAmplifying(s[i])) {
			if (p == 1) {
				cout << t << endl;
				t = "";
				p = 0;
			}
			cout << s[i] << endl;
		}
		else {
			t += removeSpace(s[i]);
			p = 1;
		}
	}
	if (p == 1) {
		cout << t << endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	int t; cin >> t; while (t--)
		solve();
	return 0;
}

/**/


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <cmath>
#include <limits>
#include <list>
#include <memory>
#include <stack>
#include <iterator>
#include <queue>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cstring>
using namespace std;

#pragma GCC optimize("Ofast")
#define ll long long
#define ld long double
#define ull unsigned long long
#define V vector
#define pp pair<ll,ll>
#define pi 4*atan(1)
#define inf 1000000000000
#define max2(a,b) ((a<b)?b:a)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) ((a>b)?b:a)
#define min3(a,b,c) min2(min2(a,b),c)
#define what_is(x) cerr << #x << " is " << x << end
#define PS push_back
#define IT(x) begin(x),end(x)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define BOOLO(x) cout << (x ? "YES" : "NO") << endl
const int mod = 1e9 + 7;

void D(V<int> a) {
	for (int i : a)
		cout << i << " ";
	cout << endl;
}

bool isAmplifying(string s) {
	for (char i : s) {
		if (i != ' ') {
			return i == '#';
		}
	}
	return 0;
}

string removeSpace(string s) {
	string o = "";
	for (char i : s) {
		if (i != ' ') {
			o += i;
		}
	}
	return o;
}

void solve() { // ctrl z to end input
	V<string> s, o;
	string t;
	while (!cin.eof()) {
		getline(cin, t);
		s.PS(t);
	}
	t = "";
	bool p = 0;
	for (string i : s) {
		if (isAmplifying(i)) {
			if (p == 1) {
				o.PS(t);
				t = "";
				p = 0;
			}
			o.PS(i);
		}
		else {
			t += removeSpace(i);
			p = 1;
		}
	}
	if (p == 1) {
		o.PS(t);
		t = "";
		p = 0;
	}
	for (int i = 0; i < o.size(); i++) {
		cout << o[i];
		if (i != o.size()-1) {
			cout << endl;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	int t; cin >> t; while (t--)
		solve();
	return 0;
}

/**/


#include<iostream>
using namespace std;
int main(){
int i,k=0;
string s;
while(getline(cin,s)){
    for(i=0;i<s.length();i++)
        if(s[i]!=' ')
            break;
    if(i==s.length() || s[i]!='#'){
        if(k==2)
            cout<<endl;
        for(i=0;i<s.length();i++)
            if(s[i]!=' ')
                cout<<s[i];
        k=1;
    }
    else{
        if(k)
            cout<<endl;
        cout<<s;
        k=2;
    }
}
cout<<endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>

using namespace std;

bool isStrong(const string& s) {
    for (char ch: s) {
        if (ch == '#') return true;
        if (ch != ' ') return false;
    }
    return false;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    freopen("1.in", "r", stdin);

    vector<string> lines;
    string line;
    while (getline(cin, line)) {
        lines.push_back(line);
    }

    string cur;
    bool hasCur = false;
    for (string s: lines) {
        if (isStrong(s)) {
            if (hasCur) cout << cur << "\n";
            cout << s << "\n";
            cur = "";
            hasCur = false;
        } else {
            s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
            cur += s;
            hasCur = true;
        }
    }
    if (hasCur) cout << cur << "\n";
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>

using namespace std;

bool isStrong(const string& s) {
    for (char ch: s) {
        if (ch == '#') return true;
        if (ch != ' ') return false;
    }
    return false;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    freopen("1.in", "r", stdin);

    vector<string> lines;
    string line;
    while (getline(cin, line)) {
        lines.push_back(line);
    }

    string cur;
    for (string s: lines) {
        if (isStrong(s)) {
            if (!cur.empty()) cout << cur << "\n";
            cout << s << "\n";
            cur = "";
        } else {
            s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
            cur += s;
        }
    }
    if (!cur.empty()) cout << cur << "\n";
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;

using namespace __gnu_pbds; // or pb_ds;

template<typename T, typename B = null_type>
using oset = tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

template<typename T>
class minQ{
	deque<tuple<T, int, int> > p;
	T delta;
	int sz;
public:
	minQ() : delta(0), sz(0) {}
	inline int size() const{ return sz; }
	inline void add(T x){ delta += x; }
	inline void push(T x, int id){
		x -= delta, sz++;
		int t = 1;
		while(p.size() > 0 && get<0>(p.back()) >= x)
			t += get<1>(p.back()), p.pop_back();
		p.emplace_back(x, t, id);
	}
	inline void pop(){
		get<1>(p.front())--, sz--;
		if(!get<1>(p.front())) p.pop_front();
	}
	T getmin() const{ return get<0>(p.front())+delta; }
	int getid() const{ return get<2>(p.front()); }
};

namespace CHT {
	using ll = long long;
	struct Line {
		mutable ll m, b, p;
		bool operator<(const Line& o) const { return m < o.m; }
		bool operator<(ll x) const { return p < x; }
	};

	struct LineContainer : multiset<Line, less<>> { // CPP14 only
		// (for doubles, use inf = 1/.0, div(a,b) = a/b)
		const ll inf = LLONG_MAX;
		ll div(ll a, ll b) { // floored division
			return a / b - ((a ^ b) < 0 && a % b); }
		bool isect(iterator x, iterator y) {
			if (y == end()) { x->p = inf; return false; }
			if (x->m == y->m) x->p = x->b > y->b ? inf : -inf;
			else x->p = div(y->b - x->b, x->m - y->m);
			return x->p >= y->p;
		}
		void add(ll m, ll b) {
			auto z = insert({m, b, 0}), y = z++, x = y;
			while (isect(y, z)) z = erase(z);
			if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
			while ((y = x) != begin() && (--x)->p >= y->p)
				isect(x, erase(y));
		}
		ll query(ll x) {
			assert(!empty());
			auto l = *lower_bound(x);
			return l.m * x + l.b;
		}
	};
};

int INP,AM,REACHEOF;
#define BUFSIZE (1 << 12)
char BUF[BUFSIZE+1], *inp=BUF;
#define GETCHAR(INP) { \
    if(!*inp && !REACHEOF) { \
        memset(BUF,0,sizeof BUF);\
        int inpzzz = (int)fread(BUF,1,BUFSIZE,stdin);\
        if (inpzzz != BUFSIZE) REACHEOF = true;\
        inp=BUF; \
    } \
    INP=*inp++; \
}
#define DIG(a) (((a)>='0')&&((a)<='9'))
#define GN(j) { \
    AM=0;\
    GETCHAR(INP); while(!DIG(INP) && INP!='-') GETCHAR(INP);\
    if (INP=='-') {AM=1;GETCHAR(INP);} \
    j=INP-'0'; GETCHAR(INP); \
    while(DIG(INP)){j=10*j+(INP-'0');GETCHAR(INP);} \
    if (AM) j=-j;\
}

#define ff first
#define ss second

const int mod = 1e9+7;
int add(int a, int b) {
	return a + b < mod ? a + b : a + b - mod;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

using ll = long long;

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	string s;

	auto ampl = [](string str) {
		int i = 0;
		while(i < (int)str.size() and str[i] == ' ') i++;
		return str[i] == '#';
	};
	auto compress = [](string str) {
		string ans;
		for(char c : str) {
			if(c != ' ') {
				ans += c;
			}
		}
		return ans;
	};
	vector<pair<string, bool>> ans;

	while(getline(cin, s)) {
		if(ampl(s)) ans.emplace_back(s, true);
		else {
			s = compress(s);
			if(!ans.empty() and !ans.back().ss) {
				ans.back().ff += s;
			}
			else ans.emplace_back(s, false);
		}
	}

	for(auto [str, b] : ans) {
		cout << str << "\n";
	}
}


#include<iostream>
using namespace std;
int main() {
	int i,k=0;
	string s;
	while(getline(cin,s))	{
		for(i=0;i<s.length();i++) if(s[i]!=' ') break;
			if(i==s.length() || s[i]!='#') {
				if(k==2) cout<<endl;
				for(i=0;i<s.length();i++) if(s[i]!=' ') cout<<s[i];
				k=1;
			}
			else {
				if(k) cout<<endl;
				cout<<s;
				k=2;
			}
	}
	cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
typedef unsigned long long ull;
const int N=6100000;
char s[N],ret[N];
int top,l,pre;
int check()
{
	for(int i=0; i<l; i++)
	{
		if(s[i]==' ')
			continue;
		else if(s[i]=='#')
			return 1;
		else	return 0;
	}
	return 0;
}

void solve()
{
	for(int i=0; i<l; i++)
	{
		if(s[i]==' ')
			continue;
		ret[top++]=s[i];
	}
}

void show()
{
	ret[top]='\0';
	printf("%s\n",ret);
}
int main()
{
	top=0,pre=0;
	while(gets(s)!=NULL)
	{
		l=strlen(s);
		if(check())
		{
			if(pre)
				show();
			printf("%s\n",s);
			pre=0;
			top=0;
		}
		else
		{
			solve();
			pre=1;
		}
	}
	if(pre)
		show();
 }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    bool first=1;
    string old="";
    while(getline(cin,s)){
        bool amp=0;
        for (auto x:s){
            if (x!=' '){
                if (x=='#')amp=1;
                else amp=0;
                break;
            }
        }
        if (amp){
            if (!first)cout<<old<<endl;
            old="";
            cout<<s<<endl;
            first=1;
        } else {
            for (auto x:s)if (x!=' ')old+=x;
            first=0;
        }
    }
    if (!first)cout<<old<<endl;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define j(n) (ll j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
    Mapogo;
	string x, rem = "";
	bool flag = 0;
	while (getline(cin, x)) {
		bool is = false;
		for i(x.size()) {
			if (x[i] != ' ') {
				is = (x[i] == '#');
				break;
			}
		}
		if (is) {
			if (flag)
				cout << rem << endl;
			rem = "";
			cout << x << endl;
			flag = 0;
		}
		else {
			flag = 1;
			string s = "";
			for i(x.size()) {
				if (x[i] != ' ')s += x[i];
			}
			rem += s;
		}
	}
	if (flag)
		cout << rem << endl;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (ll i=0;i<n;i++)
#define j(n) (ll j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
    Mapogo;
	string x, rem = "";
	cin >> x;
	while (getline(cin, x)) {
		bool is = false;
		for i(x.size()) {
			if (x[i] != ' ') {
				is = (x[i] == '#');
				break;
			}
		}
		if (is) {
			cout << rem << endl;
			rem = "";
			cout << x << endl;
		}
		else {
			for i(x.size()) {
				if (x[i] != ' ')rem += x[i];
			}
		}
	}
	cout << rem;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (ll i=0;i<n;i++)
#define j(n) (ll j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
    Mapogo;
	string x, rem = "";
	bool flag = 0;
	while (getline(cin, x)) {
		bool is = false;
		for (int i = 0; i < x.length(); ++i) {
			if (x[i] != ' ') {
				is = (x[i] == '#');
				break;
			}
		}
		if (is) {
			if (flag)
				cout << rem << endl;
			rem = "";
			cout << x << endl;
			flag = 0;
		}
		else {
			flag = 1;
			string s = "";
			for (int i = 0; i < x.length(); ++i) {
				if (x[i] != ' ')s += x[i];
			}
			rem += s;
		}
	}
	if (flag)
		cout << rem;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (ll i=0;i<n;i++)
#define j(n) (ll j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
    Mapogo;
	string x, rem = "";
	bool flag = 0;
	while (getline(cin, x)) {
		bool is = false;
		for i(x.length()) {
			if (x[i] != ' ') {
				is = (x[i] == '#');
				break;
			}
		}
		if (is) {
			if (flag)
				cout << rem << endl;
			rem = "";
			cout << x << endl;
			flag = 0;
		}
		else {
			flag = 1;
			string s = "";
			for i(x.length()) {
				if (x[i] != ' ')s += x[i];
			}
			rem += s;
		}
	}
	if (flag)
		cout << rem;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (ll i=0;i<n;i++)
#define j(n) (ll j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
    Mapogo;
	string x, rem = "";
	cin >> x;
	while (getline(cin, x)) {
		bool is = false;
		for i(x.size()) {
			if (x[i] != ' ')is = (x[i] == '#');
		}
		if (is) {
			cout << rem << endl;
			rem = "";
			cout << x << endl;
		}
		else {
			for i(x.size()) {
				if (x[i] != ' ')rem += x[i];
			}
		}
	}
	cout << rem;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (ll i=0;i<n;i++)
#define j(n) (ll j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
    Mapogo;
	string x, rem = "";
	bool flag = 0;
	while (getline(cin, x)) {
		bool is = false;
		for (int i = 0; i < x.length(); ++i) {
			if (x[i] != ' ') {
				is = (x[i] == '#');
				break;
			}
		}
		if (is) {
			if (flag)
				cout << rem << endl;
			rem = "";
			cout << x << endl;
			flag = 0;
		}
		else {
			flag = 1;
			string s = "";
			for (int i = 0; i < x.length(); ++i) {
				if (x[i] != ' ')s += x[i];
			}
			rem += s;
		}
	}
	if (flag)
		cout << rem << endl;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (ll i=0;i<n;i++)
#define j(n) (ll j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
    Mapogo;
	string x, rem = "";
	while (getline(cin, x)) {
		bool is = false;
		for i(x.length()) {
			if (x[i] != ' ' and x[i]=='#') {
				is = 1;
				break;
			}
		}
		if (is) {
			cout << rem << endl;
			rem = "";
			cout << x << endl;
		}
		else {
			for i(x.length()) {
				if (x[i] != ' ')rem += x[i];
			}
		}
	}
	cout << rem;
	return 0;
}


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

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define bp __builtin_popcountll
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<ll,ll>
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<pii,vector<pii>,greater<pii> >
#define maxQueue priority_queue<pii>
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

int main()
{
	FAST;

	string s;
	bool f = false, ff = true;

	while (getline(cin, s)){
		ff = true;

		for (int i=0; i<s.size(); i++){

			if (s[i] != ' '){
				ff = false;
				if (s[i] != '#'){
					for (int i=0; i<s.size(); i++){
						if (s[i] != ' ') cout << s[i];
					}
					f = true;

				} else {
					if (f) cout << endl;
					cout << s << endl;
					f = false;
				}
				break;
			}
		}
		if (ff)f = true;
	}
	if (f) cout << endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main(void)
{
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
//	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		int flag=-1;
		string s;
		while(getline(cin,s))
		{
			int n = s.length();
			int i=0;
			for(i=0;i<n;i++)
			{
				if(s[i] !=' ')
					break;
			}
			if(s[i] == '#')
			{
				if(flag == 1)
					cout<<endl;
				cout<<s;//<<endl;
				flag = 0;
				//return 0;
			}
			//else if(i == n)
			else
			{
				if(flag == 0)
					cout<<endl;
				for(int j=i;j<n;j++)
				{
					if(s[j] != ' ' && s[j] != '\n')
						cout<<s[j];//<<"testa";
				}
				flag = 1;
				//return 0;
			}
		}
		cout<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main(void)
{
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
//	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		int flag=0;
		string s;
		while(getline(cin,s))
		{
			int n = s.length();
			int i=0;
			for(i=0;i<n;i++)
			{
				if(s[i] !=' ')
					break;
			}
			if(s[i] == '#')
			{
				if(flag == 1)
					cout<<endl;
				cout<<s;//<<endl;
				flag = 0;
				//return 0;
			}
			//else if(i == n)
			else
			{
				if(flag == 0)
					cout<<endl;
				for(int j=i;j<n;j++)
				{
					if(s[j] != ' ' && s[j] != '\n')
						cout<<s[j];//<<"testa";
				}
				flag = 1;
				//return 0;
			}
		}
		cout<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		int flag=-1;
		string s;
		while(getline(cin,s))
		{
			int n = s.length();
			int i=0;
			for(i=0;i<n;i++)
			{
				if(s[i] !=' ')
					break;
			}
			if(s[i] == '#' && i != n)
			{
				if(flag == 1)
					cout<<endl;
				cout<<s<<endl;
				flag = 0;
				//return 0;
			}
			//else if(i == n)
			else
			{
				for(int j=i;j<n;j++)
				{
					if(s[j] != ' ' && s[j] != '\n')
						cout<<s[j];//<<"testa";
				}
				flag = 1;
				//return 0;
			}
		}
		if(flag == 1)
			cout<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		int flag=0;
		string s;
		while(getline(cin,s))
		{
			int n = s.length();
			int i=0;
			for(i=0;i<n;i++)
			{
				if(s[i] !=' ')
					break;
			}
			if(s[i] == '#')
			{
				if(flag == 1)
					cout<<endl;
				cout<<s;//<<endl;
				flag = 0;
			}
			//else if(i == n)
			else
			{
				if(flag == 0)
					cout<<endl;
				for(int j=i;j<n;j++)
				{
					if(s[j] != ' ' && s[j] != '\n')
						cout<<s[j];
				}
				flag = 1;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int

using namespace std;

int main(void)
{
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
//	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		int flag=0;
		string s;
		while(getline(cin,s))
		{
			int n = s.length();
			int i=0;
			for(i=0;i<n;i++)
			{
				if(s[i] !=' ')
					break;
			}
			if(s[i] == '#')
			{
				if(flag == 1)
					cout<<endl;
				cout<<s;//<<endl;
				flag = 0;
				//return 0;
			}
			//else if(i == n)
			else
			{
				if(flag == 0)
					cout<<endl;
				for(int j=i;j<n;j++)
				{
					if(s[j] != ' ' && s[j] != '\n')
						cout<<s[j];//<<"testa";
				}
				flag = 1;
				//return 0;
			}
		}
	}
	return 0;
}


/*                                  /   \                                                                   (Hello)//JSM//*/
/*                                 /*****\                                                                              */
/*                                /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<bits/stdc++.h>
#include<cstring>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define ll long long int
#define ld long double
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define mkt make_tuple
#define all(v ) sort(v.begin(), v.end());
#define resrt(v ) sort(v.rbegin(), v.rend());
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vi vector<ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll bin_srch(ll L[], ll N,ll item){ll flag=-2;int l=0,u=N-1,m;while(l<=u) {m=(l+u)/2;if(item==L[m]) {flag=m-1; break;} else if(item>L[m]) l=m-1; else u=m+1;} return flag;}
ll properdiv(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll minDissame(ll a[], ll n)  {map<ll,ll> hmap; ll minDistance = INT_MAX;  ll previousIndex = 0, currentIndex = 0;  for (ll i = 0; i < n; i++) {  if (hmap.find(a[i])!=hmap.end()) {  currentIndex = i;     previousIndex = hmap[a[i]];   minDistance = min((currentIndex -        previousIndex),minDistance);        }hmap[a[i]] = i;  }    return (minDistance == INT_MAX ? -1 : minDistance);  }
ll minDistanytwo(ll arr[], ll n, ll x, ll y) {ll p = -1, min_dist = INT_MAX; for(ll i=0 ; i<n ; i++) {if(arr[i]==x || arr[i]==y) {if( p != -1 && arr[i] != arr[p])  min_dist = min(min_dist , i-p); p=i;  }} if(min_dist==INT_MAX) return -1; return min_dist; }
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
string fumn(string s){string p;for(ll i = 0; i < s.length(); i++)if(isalpha(s[i]))p+=toupper(s[i]);return p;}
ll turns(string S,string SS){ ll i,cc=0,l=S.length();fo(i,l){ if(S[i]!=SS[i]) cc++; } return cc/2;}
ld polygonArea(ld X[], ld Y[], ll n) {  double area = 0.0; ll j = n - 1; for (ll i = 0; i < n; i++) {   area += (X[j] + X[i]) * (Y[j] - Y[i]);  j = i;  }  return abs(area / 2.0); }
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; }
//s2>s1;if(not) rtrn -1;
ll hhh2(unsigned ll n) {   if (n < 1)  return 0; ll res = 1;  ll u=0; for (ll i=0; i<8*sizeof(unsigned ll); i++) {    ll curr = 1 << i; if (curr > n)      break;   u++;  res = curr;} return u; }
ld ldgcd(ld a,ld b){ return a<0.0001?b:ldgcd(fmod(b,a),a);}
void onesol(ll a,ll b,ll& x,ll& y,ll& g) {if(!b) {g=a;x=1;y=0;} else{onesol(b,a%b,y,x,g);y-=a/b*x;}}
/*struct pp
{
	ll x,y;
};*/
/*PLEASE START @ANU$HK GAUTAM
KEEP PATIENCE AND CONFIDENCE*/
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);		  ll t=1;

//	   cin>>t;

	      while(t--)
{
/*
   #   include <cstdio>

using namespace std;

int main     (   ){
puts("Hello # World"); #
#
}
*/
ll i,n,j,k,l,g;
string s;
ll f=-1;
while(getline(cin,s))
{char aa='o';
	fo(i,s.length())
	{
		if(s[i]==' ')
		continue;
		else
		{ aa=s[i];
			j=i;
			break;
		}
	}
	if(aa=='#'&&f==-1)
	{
		cout<<s;
		EE;
	}
	else if(aa=='#'&&f==1)
	{
		ee;
		cout<<s;
		EE;
	}
	else
	{
		for(i=j;i<s.length();i++)
		{
			if(s[i]!=' ')
			cout<<s[i];
		}
		f=1;
	}
}
}
return 0;
}


/*                                  /   \                                                                   (Hello)//JSM//*/
/*                                 /*****\                                                                              */
/*                                /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<bits/stdc++.h>
#include<cstring>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define ll long long int
#define ld long double
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define mkt make_tuple
#define all(v ) sort(v.begin(), v.end());
#define resrt(v ) sort(v.rbegin(), v.rend());
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vi vector<ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll bin_srch(ll L[], ll N,ll item){ll flag=-2;int l=0,u=N-1,m;while(l<=u) {m=(l+u)/2;if(item==L[m]) {flag=m-1; break;} else if(item>L[m]) l=m-1; else u=m+1;} return flag;}
ll properdiv(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll minDissame(ll a[], ll n)  {map<ll,ll> hmap; ll minDistance = INT_MAX;  ll previousIndex = 0, currentIndex = 0;  for (ll i = 0; i < n; i++) {  if (hmap.find(a[i])!=hmap.end()) {  currentIndex = i;     previousIndex = hmap[a[i]];   minDistance = min((currentIndex -        previousIndex),minDistance);        }hmap[a[i]] = i;  }    return (minDistance == INT_MAX ? -1 : minDistance);  }
ll minDistanytwo(ll arr[], ll n, ll x, ll y) {ll p = -1, min_dist = INT_MAX; for(ll i=0 ; i<n ; i++) {if(arr[i]==x || arr[i]==y) {if( p != -1 && arr[i] != arr[p])  min_dist = min(min_dist , i-p); p=i;  }} if(min_dist==INT_MAX) return -1; return min_dist; }
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
string fumn(string s){string p;for(ll i = 0; i < s.length(); i++)if(isalpha(s[i]))p+=toupper(s[i]);return p;}
ll turns(string S,string SS){ ll i,cc=0,l=S.length();fo(i,l){ if(S[i]!=SS[i]) cc++; } return cc/2;}
ld polygonArea(ld X[], ld Y[], ll n) {  double area = 0.0; ll j = n - 1; for (ll i = 0; i < n; i++) {   area += (X[j] + X[i]) * (Y[j] - Y[i]);  j = i;  }  return abs(area / 2.0); }
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; }
//s2>s1;if(not) rtrn -1;
ll hhh2(unsigned ll n) {   if (n < 1)  return 0; ll res = 1;  ll u=0; for (ll i=0; i<8*sizeof(unsigned ll); i++) {    ll curr = 1 << i; if (curr > n)      break;   u++;  res = curr;} return u; }
ld ldgcd(ld a,ld b){ return a<0.0001?b:ldgcd(fmod(b,a),a);}
void onesol(ll a,ll b,ll& x,ll& y,ll& g) {if(!b) {g=a;x=1;y=0;} else{onesol(b,a%b,y,x,g);y-=a/b*x;}}
/*struct pp
{
	ll x,y;
};*/
/*PLEASE START @ANU$HK GAUTAM
KEEP PATIENCE AND CONFIDENCE*/
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);		  ll t=1;

//	   cin>>t;

	      while(t--)
{
/*
   #   include <cstdio>

using namespace std;

int main     (   ){
puts("Hello # World"); #
#
}
*/
ll i,n,j,k,l,g;
string s;
ll f=-1;
while(getline(cin,s))
{char aa=' ';
	fo(i,s.length())
	{
		if(s[i]==' ')
		continue;
		else
		{ aa=s[i];
			j=i;
			break;
		}
	}
	if(aa=='#'&&f==-1)
	{f=-1;
		cout<<s;
		EE;
	}
	else if(aa=='#'&&f==1)
	{f=-1;
		ee;
		cout<<s;
		EE;
	}
	else
	{
		for(i=j;i<s.length();i++)
		{
			if(s[i]!=' ')
			cout<<s[i];
		}
		f=1;
	}
}
}
return 0;
}


/*                                  /   \                                                                   (Hello)//JSM//*/
/*                                 /*****\                                                                              */
/*                                /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<bits/stdc++.h>
#include<cstring>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define ll long long int
#define ld long double
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define mkt make_tuple
#define all(v ) sort(v.begin(), v.end());
#define resrt(v ) sort(v.rbegin(), v.rend());
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vi vector<ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll bin_srch(ll L[], ll N,ll item){ll flag=-2;int l=0,u=N-1,m;while(l<=u) {m=(l+u)/2;if(item==L[m]) {flag=m-1; break;} else if(item>L[m]) l=m-1; else u=m+1;} return flag;}
ll properdiv(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll minDissame(ll a[], ll n)  {map<ll,ll> hmap; ll minDistance = INT_MAX;  ll previousIndex = 0, currentIndex = 0;  for (ll i = 0; i < n; i++) {  if (hmap.find(a[i])!=hmap.end()) {  currentIndex = i;     previousIndex = hmap[a[i]];   minDistance = min((currentIndex -        previousIndex),minDistance);        }hmap[a[i]] = i;  }    return (minDistance == INT_MAX ? -1 : minDistance);  }
ll minDistanytwo(ll arr[], ll n, ll x, ll y) {ll p = -1, min_dist = INT_MAX; for(ll i=0 ; i<n ; i++) {if(arr[i]==x || arr[i]==y) {if( p != -1 && arr[i] != arr[p])  min_dist = min(min_dist , i-p); p=i;  }} if(min_dist==INT_MAX) return -1; return min_dist; }
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
string fumn(string s){string p;for(ll i = 0; i < s.length(); i++)if(isalpha(s[i]))p+=toupper(s[i]);return p;}
ll turns(string S,string SS){ ll i,cc=0,l=S.length();fo(i,l){ if(S[i]!=SS[i]) cc++; } return cc/2;}
ld polygonArea(ld X[], ld Y[], ll n) {  double area = 0.0; ll j = n - 1; for (ll i = 0; i < n; i++) {   area += (X[j] + X[i]) * (Y[j] - Y[i]);  j = i;  }  return abs(area / 2.0); }
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; }
//s2>s1;if(not) rtrn -1;
ll hhh2(unsigned ll n) {   if (n < 1)  return 0; ll res = 1;  ll u=0; for (ll i=0; i<8*sizeof(unsigned ll); i++) {    ll curr = 1 << i; if (curr > n)      break;   u++;  res = curr;} return u; }
ld ldgcd(ld a,ld b){ return a<0.0001?b:ldgcd(fmod(b,a),a);}
void onesol(ll a,ll b,ll& x,ll& y,ll& g) {if(!b) {g=a;x=1;y=0;} else{onesol(b,a%b,y,x,g);y-=a/b*x;}}
/*struct pp
{
	ll x,y;
};*/
/*PLEASE START @ANU$HK GAUTAM
KEEP PATIENCE AND CONFIDENCE*/
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);		  ll t=1;

//	   cin>>t;

	      while(t--)
{
/*
   #   include <cstdio>

using namespace std;

int main     (   ){
puts("Hello # World"); #
#
}
*/
ll i,n,j,k,l,g;
string s;
ll f=2;
while(getline(cin,s))
{char aa=' ';
	fo(i,s.length())
	{
		if(s[i]==' ')
		continue;
		else
		{ aa=s[i];
			j=i;
			break;
		}
	}
	if(aa=='#'&&f==2)
	{f=1;
		cout<<s;
	///	EE;
	continue;
	//	break;
	}
	else if(aa=='#')
	{
	    if(f==-1)
		ee;
		f=1;
		cout<<s;
	continue;
	}
	else
	{
		if(f==1)
		EE;
		for(i=j;i<s.length();i++)
		{
			if(s[i]!=' ')
			cout<<s[i];
		}
		f=-1;
		continue;
	}
}
}
return 0;
}


/*                                  /   \                                                                   (Hello)//JSM//*/
/*                                 /*****\                                                                              */
/*                                /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<bits/stdc++.h>
#include<cstring>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define ll long long int
#define ld long double
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define mkt make_tuple
#define all(v ) sort(v.begin(), v.end());
#define resrt(v ) sort(v.rbegin(), v.rend());
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vi vector<ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll bin_srch(ll L[], ll N,ll item){ll flag=-2;int l=0,u=N-1,m;while(l<=u) {m=(l+u)/2;if(item==L[m]) {flag=m-1; break;} else if(item>L[m]) l=m-1; else u=m+1;} return flag;}
ll properdiv(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll minDissame(ll a[], ll n)  {map<ll,ll> hmap; ll minDistance = INT_MAX;  ll previousIndex = 0, currentIndex = 0;  for (ll i = 0; i < n; i++) {  if (hmap.find(a[i])!=hmap.end()) {  currentIndex = i;     previousIndex = hmap[a[i]];   minDistance = min((currentIndex -        previousIndex),minDistance);        }hmap[a[i]] = i;  }    return (minDistance == INT_MAX ? -1 : minDistance);  }
ll minDistanytwo(ll arr[], ll n, ll x, ll y) {ll p = -1, min_dist = INT_MAX; for(ll i=0 ; i<n ; i++) {if(arr[i]==x || arr[i]==y) {if( p != -1 && arr[i] != arr[p])  min_dist = min(min_dist , i-p); p=i;  }} if(min_dist==INT_MAX) return -1; return min_dist; }
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
string fumn(string s){string p;for(ll i = 0; i < s.length(); i++)if(isalpha(s[i]))p+=toupper(s[i]);return p;}
ll turns(string S,string SS){ ll i,cc=0,l=S.length();fo(i,l){ if(S[i]!=SS[i]) cc++; } return cc/2;}
ld polygonArea(ld X[], ld Y[], ll n) {  double area = 0.0; ll j = n - 1; for (ll i = 0; i < n; i++) {   area += (X[j] + X[i]) * (Y[j] - Y[i]);  j = i;  }  return abs(area / 2.0); }
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; }
//s2>s1;if(not) rtrn -1;
ll hhh2(unsigned ll n) {   if (n < 1)  return 0; ll res = 1;  ll u=0; for (ll i=0; i<8*sizeof(unsigned ll); i++) {    ll curr = 1 << i; if (curr > n)      break;   u++;  res = curr;} return u; }
ld ldgcd(ld a,ld b){ return a<0.0001?b:ldgcd(fmod(b,a),a);}
void onesol(ll a,ll b,ll& x,ll& y,ll& g) {if(!b) {g=a;x=1;y=0;} else{onesol(b,a%b,y,x,g);y-=a/b*x;}}
/*struct pp
{
	ll x,y;
};*/
/*PLEASE START @ANU$HK GAUTAM
KEEP PATIENCE AND CONFIDENCE*/
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);		  ll t=1;

//	   cin>>t;

	      while(t--)
{
/*
   #   include <cstdio>

using namespace std;

int main     (   ){
puts("Hello # World"); #
#
}
*/
ll i,n,j,k,l,g;
string s;
ll f=2;
while(getline(cin,s))
{char aa=' ';
	fo(i,s.length())
	{
		if(s[i]==' ')
		continue;
		else
		{ aa=s[i];
			j=i;
			break;
		}
	}
	if(aa=='#'&&f==2)
	{f=1;
		cout<<s;
	///	EE;
	continue;
	//	break;
	}
	else if(aa=='#')
	{
	    ee;
		f=1;
		cout<<s;
	continue;
	}
	else
	{
		if(f==1)
		EE;
		for(i=j;i<s.length();i++)
		{
			if(s[i]!=' ')
			cout<<s[i];
		}
		f=-1;
		continue;
	}
}
EE;
}
return 0;
}


/*                                  /   \                                                                   (Hello)//JSM//*/
/*                                 /*****\                                                                              */
/*                                /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<bits/stdc++.h>
#include<cstring>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define ll long long int
#define ld long double
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define mkt make_tuple
#define all(v ) sort(v.begin(), v.end());
#define resrt(v ) sort(v.rbegin(), v.rend());
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vi vector<ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll bin_srch(ll L[], ll N,ll item){ll flag=-2;int l=0,u=N-1,m;while(l<=u) {m=(l+u)/2;if(item==L[m]) {flag=m-1; break;} else if(item>L[m]) l=m-1; else u=m+1;} return flag;}
ll properdiv(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll minDissame(ll a[], ll n)  {map<ll,ll> hmap; ll minDistance = INT_MAX;  ll previousIndex = 0, currentIndex = 0;  for (ll i = 0; i < n; i++) {  if (hmap.find(a[i])!=hmap.end()) {  currentIndex = i;     previousIndex = hmap[a[i]];   minDistance = min((currentIndex -        previousIndex),minDistance);        }hmap[a[i]] = i;  }    return (minDistance == INT_MAX ? -1 : minDistance);  }
ll minDistanytwo(ll arr[], ll n, ll x, ll y) {ll p = -1, min_dist = INT_MAX; for(ll i=0 ; i<n ; i++) {if(arr[i]==x || arr[i]==y) {if( p != -1 && arr[i] != arr[p])  min_dist = min(min_dist , i-p); p=i;  }} if(min_dist==INT_MAX) return -1; return min_dist; }
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
string fumn(string s){string p;for(ll i = 0; i < s.length(); i++)if(isalpha(s[i]))p+=toupper(s[i]);return p;}
ll turns(string S,string SS){ ll i,cc=0,l=S.length();fo(i,l){ if(S[i]!=SS[i]) cc++; } return cc/2;}
ld polygonArea(ld X[], ld Y[], ll n) {  double area = 0.0; ll j = n - 1; for (ll i = 0; i < n; i++) {   area += (X[j] + X[i]) * (Y[j] - Y[i]);  j = i;  }  return abs(area / 2.0); }
ll isSubstr(string s1, string s2) {   ll M = s1.length();    ll N = s2.length();  for (ll i = 0; i <= N - M; i++) { ll j; for (j = 0; j < M; j++) if (s2[i + j] != s1[j])  break;         if (j == M) return i;   } return -1; }
//s2>s1;if(not) rtrn -1;
ll hhh2(unsigned ll n) {   if (n < 1)  return 0; ll res = 1;  ll u=0; for (ll i=0; i<8*sizeof(unsigned ll); i++) {    ll curr = 1 << i; if (curr > n)      break;   u++;  res = curr;} return u; }
ld ldgcd(ld a,ld b){ return a<0.0001?b:ldgcd(fmod(b,a),a);}
void onesol(ll a,ll b,ll& x,ll& y,ll& g) {if(!b) {g=a;x=1;y=0;} else{onesol(b,a%b,y,x,g);y-=a/b*x;}}
/*struct pp
{
	ll x,y;
};*/
/*PLEASE START @ANU$HK GAUTAM
KEEP PATIENCE AND CONFIDENCE*/
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);		  ll t=1;

//	   cin>>t;

	      while(t--)
{
/*
   #   include <cstdio>

using namespace std;

int main     (   ){
puts("Hello # World"); #
#
}
*/
ll i,n,j,k,l,g;
string s;
ll f=-1;
while(getline(cin,s))
{char aa='o';
	fo(i,s.length())
	{
		if(s[i]==' ')
		continue;
		else
		{ aa=s[i];
			j=i;
			break;
		}
	}
	if(aa=='#'&&f==-1)
	{f=-1;
		cout<<s;
		EE;
	}
	else if(aa=='#'&&f==1)
	{f=-1;
		ee;
		cout<<s;
		EE;
	}
	else
	{
		for(i=j;i<s.length();i++)
		{
			if(s[i]!=' ')
			cout<<s[i];
		}
		f=1;
	}
}
}
return 0;
}