#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
char s[1001][1001];
int l[1001];
int main() {
  int w = 0;
  int n = 0;
  while (gets(s[n])) {
    if (!s[0]) break;
    l[n] = strlen(s[n]);
    if (l[n] > w) w = l[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 - l[i]) / 2;
    int b = w - l[i] - a;
    if (a != b && l[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;
}
