#include <bits/stdc++.h>
int main() {
  char str[1500][1001];
  int len[1500], max = 0, i, j, n = 0, flag;
  while (gets(str[n])) {
    len[n] = strlen(str[n]);
    if (len[n] > max) max = len[n];
    n++;
  }
  flag = 0;
  for (i = 0; i <= max + 1; i++) printf("*");
  printf("\n");
  for (i = 0; i < n; i++) {
    printf("*");
    if ((max - len[i]) % 2 == 0) {
      for (j = 0; j < (max - len[i]) / 2; j++) printf(" ");
      printf("%s", str[i]);
      for (j = 0; j < (max - len[i]) / 2; j++) printf(" ");
    } else {
      if (flag) {
        for (j = 0; j < max - len[i] - (max - len[i]) / 2; j++) printf(" ");
        printf("%s", str[i]);
        for (j = 0; j < (max - len[i]) / 2; j++) printf(" ");
        flag = 0;
      } else {
        for (j = 0; j < (max - len[i]) / 2; j++) printf(" ");
        printf("%s", str[i]);
        for (j = 0; j < max - len[i] - (max - len[i]) / 2; j++) printf(" ");
        flag = 1;
      }
    }
    printf("*\n");
  }
  for (i = 0; i <= max + 1; i++) printf("*");
  printf("\n");
  return 0;
}
