#include <bits/stdc++.h>
using namespace std;
char s[1005][1005];
int a[1005];
int main() {
  int n = 0, m = 0, i, j;
  while (gets(s[n]) != NULL) {
    for (a[n] = 0; s[n][a[n]]; a[n]++)
      ;
    if (a[n] > m) m = a[n];
    n++;
  }
  for (i = 1; i <= m + 2; i++) printf("*");
  printf("\n");
  int flag = 1;
  for (i = 0; i < n; i++) {
    printf("*");
    if ((m - a[i]) % 2) {
      if (flag) {
        for (j = 0; j < (m - a[i]) >> 1; j++) printf(" ");
        cout << s[i];
        for (j = 0; j <= (m - a[i]) >> 1; j++) printf(" ");
      } else {
        for (j = 0; j <= (m - a[i]) >> 1; j++) printf(" ");
        cout << s[i];
        for (j = 0; j < (m - a[i]) >> 1; j++) printf(" ");
      }
      if (flag)
        flag = 0;
      else
        flag = 1;
    } else {
      for (j = 0; j < (m - a[i]) >> 1; j++) printf(" ");
      cout << s[i];
      for (j = 0; j < (m - a[i]) >> 1; j++) printf(" ");
    }
    printf("*\n");
  }
  for (i = 1; i <= m + 2; i++) printf("*");
  return 0;
}
