#include <bits/stdc++.h>
inline char fgc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long readint() {
  long long res = 0, neg = 1;
  char c = fgc();
  for (; !isdigit(c); c = fgc())
    if (c == '-') neg = -1;
  for (; isdigit(c); c = fgc()) res = res * 10 + c - '0';
  return res * neg;
}
inline char readsingle() {
  char c;
  while (!isgraph(c = fgc())) {
  }
  return c;
}
const int MAXN = 1005;
int n = 0, mxm = 0, t = 0;
char buf[MAXN][MAXN];
int main() {
  while (gets(buf[n]) != NULL) {
    int len = strlen(buf[n]);
    mxm = std::max(mxm, len);
    n++;
  }
  for (int i = 1; i <= mxm + 2; i++) putchar('*');
  putchar('\n');
  for (int i = 0; i <= n - 1; i++) {
    putchar('*');
    int len = strlen(buf[i]), l = (mxm - len) / 2, r = mxm - len - l;
    if (l != r) {
      if (t) std::swap(l, r);
      t ^= 1;
    }
    for (int j = 1; j <= l; j++) putchar(' ');
    printf("%s", buf[i]);
    for (int j = 1; j <= r; j++) putchar(' ');
    putchar('*');
    putchar('\n');
  }
  for (int i = 1; i <= mxm + 2; i++) putchar('*');
  return 0;
}
