#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[1001][1001];
  int w = 0;
  int n = 0;
  while (gets(s[n])) {
    if (!s[0]) break;
    if (strlen(s[n]) > w) w = strlen(s[n]);
    n++;
  }
  int q = 0;
  for (int i = 0; i < w + 2; i++) printf("*");
  printf("\n");
  for (int i = 0; i < n; i++) {
    printf("*");
    int a = (w - strlen(s[i])) / 2;
    int b = w - strlen(s[i]) - a;
    if (a != b && strlen(s[i]) > 0) {
      if (q) swap(a, b);
      q ^= 1;
    }
    for (int j = 0; j < a; j++) printf(" ");
    printf("%s", s[i]);
    for (int j = 0; j < b; j++) printf(" ");
    printf("*\n");
  }
  for (int i = 0; i < w + 2; i++) printf("*");
  printf("\n");
  return 0;
}
