#include <bits/stdc++.h>
char z[1000][1000];
int main() {
  int a, b, c, i, j, k, n, m, max = -1, count;
  i = 0;
  count = 0;
  while (gets(z[i]) != NULL) {
    a = strlen(z[i]);
    i++;
    if (a > max) max = a;
  }
  for (j = 0; j < max + 2; j++) printf("*");
  printf("\n");
  for (j = 0; j < i; j++) {
    printf("*");
    a = strlen(z[j]);
    if ((max - a) % 2 == 0) {
      for (k = 0; k < (max - a) / 2; k++) printf(" ");
      printf("%s", z[j]);
      for (k = 0; k < (max - a) / 2; k++) printf(" ");
    } else {
      if (count % 2 == 0)
        for (k = 0; k < (max - a) / 2; k++) printf(" ");
      else
        for (k = 0; k < (max - a + 1) / 2; k++) printf(" ");
      printf("%s", z[j]);
      if (count % 2 == 0)
        for (k = 0; k < (max - a + 1) / 2; k++) printf(" ");
      else
        for (k = 0; k < (max - a) / 2; k++) printf(" ");
      count++;
    }
    printf("*\n");
  }
  for (j = 0; j < max + 2; j++) printf("*");
  printf("\n");
  return 0;
}
