#include <bits/stdc++.h>
using namespace std;
int main() {
  int size[1001], mx = 0, flag = 0, k = 0;
  char c[1001][1001];
  while (gets(c[k])) {
    if (!c[0]) break;
    size[k] = strlen(c[k]);
    mx = max(mx, size[k]);
    k++;
  }
  for (int i = 0; i < mx + 2; i++) cout << "*";
  cout << endl;
  for (int i = 0; i < k; i++) {
    cout << "*";
    int a = (mx - size[i]) / 2, b = mx - size[i] - a;
    if (a != b && size[i] > 0) {
      if (flag) swap(a, b);
      flag ^= 1;
    }
    for (int j = 0; j < a; j++) cout << " ";
    cout << c[i];
    for (int j = 0; j < b; j++) cout << " ";
    cout << "*" << endl;
  }
  for (int i = 0; i < mx + 2; i++) cout << "*";
  return 0;
}
