#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 << 21;
char a[MAXN], b[MAXN];
int start[MAXN];
bool flag[MAXN];
int main() {
  int len = 0, total = 1;
  char c;
  bool space = true;
  while (1) {
    c = getchar();
    if (c == EOF) break;
    if (c == '\n') {
      start[++total] = len + 1;
      space = true;
    } else {
      if (c == '#' && space) flag[total] = true;
      if (c != ' ') space = false;
      a[++len] = c;
    }
  }
  bool pre, after, now;
  int cur = 0;
  int nowline = 1;
  for (int i = 1; i <= len; i = start[nowline]) {
    pre = flag[nowline - 1];
    now = flag[nowline];
    after = flag[nowline + 1];
    if (now) {
      for (; i < start[nowline + 1]; ++i) b[++cur] = a[i];
      nowline++;
      if (nowline != total) {
        b[++cur] = '\n';
      }
    } else if (pre && after) {
      for (; i < start[nowline + 1]; ++i)
        if (a[i] != ' ') b[++cur] = a[i];
      nowline++;
      if (nowline != total) {
        b[++cur] = '\n';
      }
    } else {
      for (; i < start[nowline + 1]; ++i)
        if (a[i] != ' ') b[++cur] = a[i];
      nowline++;
      if (flag[nowline]) {
        b[++cur] = '\n';
      }
    }
  }
  for (int i = 1; i <= cur; ++i) putchar(b[i]);
  putchar('\n');
  return 0;
}
