#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int(i) = 0; (i) < (((int)(t.size()))); ++(i)) s << t[i] << " ";
  return s;
}
vector<string> L;
vector<string> R;
bool check(string line) {
  for (int(i) = 0; (i) < (line.length()); ++(i)) {
    if (line[i] != ' ') {
      if (line[i] == '#') return true;
      return false;
    }
  }
  return false;
}
string trim(string line) {
  string res;
  for (int(i) = 0; (i) < (line.length()); ++(i)) {
    if (line[i] != ' ') {
      res += line[i];
    }
  }
  return res;
}
bool empty(string line) {
  for (int(i) = 0; (i) < (line.length()); ++(i)) {
    if (line[i] != ' ') return false;
  }
  return true;
}
int main() {
  string line, tmp;
  int flag = 0;
  while (getline(cin, line)) {
    if (check(line)) {
      if (tmp != "") {
        cout << tmp << endl;
      } else if (flag == 1) {
        cout << endl;
      }
      tmp = "";
      flag = 0;
      cout << line << endl;
    } else {
      if (!empty(line)) {
        tmp += trim(line);
        flag = 2;
      } else {
        if (flag == 0) flag = 1;
      }
    }
  }
  if (tmp != "") cout << tmp << endl;
  if (flag == 1) cout << endl;
  return 0;
}
