#include <bits/stdc++.h>
using namespace std;
char s[5030][5030], leng[10030];
int main() {
  while (gets(s[0]) != NULL) {
    int cnt = 0, maxn = strlen(s[0]);
    leng[cnt] = strlen(s[cnt]);
    while (gets(s[++cnt]) != NULL) {
      if (maxn < strlen(s[cnt])) {
        maxn = strlen(s[cnt]);
      }
      leng[cnt] = strlen(s[cnt]);
    }
    for (int i = 0; i <= maxn + 1; i++) printf("*");
    printf("\n");
    int count = 0, flag = 1, ch = 0, i, j;
    for (i = 0; i < cnt; ++i) {
      printf("*");
      int l = strlen(s[i]);
      int t = maxn - l;
      if (t & 1)
        if (!flag) printf(" ");
      for (j = 1; j <= t / 2; ++j) printf(" ");
      printf("%s", s[i]);
      for (j = 1; j <= t / 2; ++j) printf(" ");
      if (t & 1) {
        if (flag) printf(" ");
        flag = !flag;
      }
      printf("*");
      puts("");
    }
    for (int i = 0; i <= maxn + 1; i++) printf("*");
    printf("\n");
  }
}
