#include <bits/stdc++.h>
using namespace std;
int n, m;
bool debug = false;
int k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
char s[1500005];
bool bl[1500005];
int main() {
  vector<string> v;
  int i;
  while (cin.getline(s, 1500005)) {
    for (i = 0; s[i] == ' ' && s[i]; i++)
      ;
    if (s[i] == '#') {
      v.push_back(s);
      bl[++k] = 1;
    } else {
      string a;
      for (int j = i; s[j]; j++)
        if (s[j] != ' ') a += s[j];
      v.push_back(a);
      bl[++k] = 0;
    }
  }
  for (i = 0; i < v.size(); i++) {
    if (!bl[i] && !bl[i + 1]) {
      if (v[i][0] == '\n') continue;
      printf("%s", &v[i][0]);
    } else if (bl[i + 1]) {
      if (i > 0) printf("\n");
      printf("%s", &v[i][0]);
    } else {
      if (i > 0) printf("\n");
      if (v[i][0] == '\n' && !bl[i + 2]) continue;
      printf("%s", &v[i][0]);
    }
  }
  printf("\n");
  return 0;
}
