#include <bits/stdc++.h>
using namespace std;
char c, str[1148576], temp[1148576];
int main() {
  int i, j, k, cnt = 0, flag;
  while (gets(temp) != NULL) {
    flag = 0;
    for (i = 0; temp[i]; ++i) {
      if (temp[i] != ' ' && temp[i] != '#') break;
      if (temp[i] == '#') flag = 1;
    }
    if (flag == 1 && cnt == 0)
      printf("%s\n", temp);
    else if (flag == 1 && cnt != 0) {
      for (i = 0; i < cnt; ++i)
        if (str[i] != ' ' && str[i] != '\n') printf("%c", str[i]);
      printf("\n");
      printf("%s\n", temp);
      cnt = 0;
    } else {
      if (temp[0] == '\0') str[cnt++] = '\n';
      for (i = 0; temp[i]; ++i) str[cnt++] = temp[i];
    }
  }
  if (cnt != 0) {
    for (i = 0; i < cnt; ++i)
      if (str[i] != ' ' && str[i] != '\n') printf("%c", str[i]);
    printf("\n");
  }
}
