#include <bits/stdc++.h>
using namespace std;
string st[1005];
int main() {
  string s[1005];
  int ind = 0, mx = 0, left, right;
  bool check = 0;
  while (getline(cin, s[ind])) {
    if (s[ind] == "end") break;
    if (s[ind].size() > mx) mx = s[ind].size();
    ind++;
  }
  mx += 2;
  for (int i = 0; i < mx; i++) {
    cout << '*';
  }
  cout << endl;
  for (int i = 0; i < ind; i++) {
    st[i] = '*';
    if ((mx - 2 - s[i].size()) % 2 == 0) {
      for (int j = 0; j < (mx - 2 - s[i].size()) / 2; j++) {
        st[i] += ' ';
      }
      st[i] += s[i];
      for (int j = 0; j < (mx - 2 - s[i].size()) / 2; j++) {
        st[i] += ' ';
      }
      st[i] += '*';
    } else {
      if (check == 0) {
        left = (mx - 2 - s[i].size()) / 2;
        right = (mx - 2 - s[i].size()) - left;
        for (int j = 0; j < left; j++) {
          st[i] += ' ';
        }
        st[i] += s[i];
        for (int j = 0; j < right; j++) {
          st[i] += ' ';
        }
        st[i] += '*';
        check = 1;
      } else {
        right = (mx - 2 - s[i].size()) / 2;
        left = (mx - 2 - s[i].size()) - right;
        for (int j = 0; j < left; j++) {
          st[i] += ' ';
        }
        st[i] += s[i];
        for (int j = 0; j < right; j++) {
          st[i] += ' ';
        }
        st[i] += '*';
        check = 0;
      }
    }
  }
  for (int i = 0; i < ind; i++) {
    cout << st[i] << endl;
  }
  for (int i = 0; i < mx; i++) {
    cout << '*';
  }
  cout << endl;
  return 0;
}
