#include <bits/stdc++.h>
using namespace std;
const long long N = 2 * 1e5 + 7;
const long double pi = 3.14159265359;
const int INF = 1e20 + 7;
const double eps = 1e-9;
const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};
int sz, mx = -INF;
string s;
vector<string> ans;
int main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  ;
  while (getline(cin, s)) {
    ans.push_back(s);
    int sss = s.size();
    mx = max(mx, sss);
    sz++;
  }
  for (int j = 0; j <= mx + 1; j++) {
    cout << "*";
  }
  cout << '\n';
  int now = 0;
  for (int cnt = 0; cnt < sz + 1; cnt++) {
    if (cnt == sz) {
      for (int j = 0; j <= mx + 1; j++) {
        cout << "*";
      }
      cout << '\n';
      continue;
    }
    string str = ans[cnt];
    int x = mx - str.size();
    cout << "*";
    if (!now) {
      for (int i = 0; i < x / 2; i++) {
        cout << ' ';
      }
    } else {
      for (int i = x / 2; i < x; i++) {
        cout << ' ';
      }
    }
    cout << str;
    if (!now) {
      for (int i = x / 2; i < x; i++) {
        cout << ' ';
      }
    } else {
      for (int i = 0; i < x / 2; i++) {
        cout << ' ';
      }
    }
    if (x % 2 == 1) {
      if (now % 2 == 1) {
        now = now - 1;
      } else {
        now = now + 1;
      }
    }
    cout << "*";
    cout << '\n';
  }
}
