#include <bits/stdc++.h>
using namespace std;
const int maxn = 1022;
string str[maxn];
int width;
int n;
string tmpstr;
int max(int x, int y) {
  if (x > y) return x;
  return y;
}
void init() {
  n = 0;
  width = 1;
  while (getline(cin, tmpstr)) {
    str[++n] = tmpstr;
    width = max(width, tmpstr.size());
  }
}
void write() {
  for (int i = 1; i <= width + 2; ++i) cout << '*';
  cout << endl;
  bool isleft = true;
  for (int i = 1; i <= n; ++i) {
    cout << '*';
    if (width % 2 == 0) {
      if (str[i].size() % 2 == 0) {
        for (int j = 1; j <= (width - str[i].size()) / 2; ++j) cout << ' ';
        cout << str[i];
        for (int j = 1; j <= (width - str[i].size()) / 2; ++j) cout << ' ';
      } else {
        if (isleft) {
          for (int j = 1; j <= (width - str[i].size()) / 2; ++j) cout << ' ';
          cout << str[i];
          for (int j = 1; j <= (width - str[i].size()) / 2 + 1; ++j)
            cout << ' ';
        } else {
          for (int j = 1; j <= (width - str[i].size()) / 2 + 1; ++j)
            cout << ' ';
          cout << str[i];
          for (int j = 1; j <= (width - str[i].size()) / 2; ++j) cout << ' ';
        }
        isleft = !isleft;
      }
    } else {
      if (str[i].size() % 2 != 0) {
        for (int j = 1; j <= (width - str[i].size()) / 2; ++j) cout << ' ';
        cout << str[i];
        for (int j = 1; j <= (width - str[i].size()) / 2; ++j) cout << ' ';
      } else {
        if (isleft) {
          for (int j = 1; j <= (width - str[i].size()) / 2; ++j) cout << ' ';
          cout << str[i];
          for (int j = 1; j <= (width - str[i].size()) / 2 + 1; ++j)
            cout << ' ';
        } else {
          for (int j = 1; j <= (width - str[i].size()) / 2 + 1; ++j)
            cout << ' ';
          cout << str[i];
          for (int j = 1; j <= (width - str[i].size()) / 2; ++j) cout << ' ';
        }
        isleft = !isleft;
      }
    }
    cout << '*' << endl;
  }
  for (int i = 1; i <= width + 2; ++i) cout << '*';
  cout << endl;
}
int main() {
  init();
  write();
  return 0;
}
