#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> V;
  string s;
  int len = 0;
  int maxi = 0;
  int y = 0;
  while (getline(cin, s, '\n') && y < 6) {
    V.push_back(s);
    len++;
    maxi = max(maxi, (int)s.size());
  }
  int rr = 0;
  for (int i = 0; i < maxi + 2; i++) cout << '*';
  cout << endl;
  for (int i = 0; i < len; i++) {
    cout << '*';
    int x = maxi - V[i].size();
    if ((maxi - V[i].size()) % 2 != 0) rr++;
    if (V[i][0] == '\n') {
      x = maxi;
    }
    for (int j = 0; j < x / 2 + ((x % 2 != 0) & !(rr & 1)); j++) cout << ' ';
    cout << V[i];
    for (int j = 0; j < x / 2 + ((x % 2 != 0) & (rr & 1)); j++) cout << ' ';
    cout << '*' << endl;
  }
  for (int i = 0; i < maxi + 2; i++) cout << '*';
  cout << endl;
  return 0;
}
