#include <bits/stdc++.h>
using namespace std;
int line_len = 0;
vector<string> lines;
int main() {
  string s;
  while (!cin.eof()) {
    getline(cin, s);
    if (cin.eof()) break;
    lines.push_back(s);
    if (s.size() > line_len) line_len = s.size();
  }
  string top_bot = "";
  for (int i = 0; i < line_len + 2; i++) top_bot += "*";
  cout << top_bot << endl;
  bool left = true;
  int left_spaces, right_spaces;
  for (int i = 0; i < lines.size(); i++) {
    left_spaces = (line_len - lines[i].size()) / 2;
    right_spaces = (line_len - lines[i].size() + 1) / 2;
    if ((line_len - lines[i].size()) % 2 != 0) {
      if (left) {
        left_spaces = (line_len - lines[i].size()) / 2;
        right_spaces = (line_len - lines[i].size() + 1) / 2;
      } else {
        left_spaces = (line_len - lines[i].size() + 1) / 2;
        right_spaces = (line_len - lines[i].size()) / 2;
      }
      left = !left;
    }
    cout << "*";
    for (int j = 0; j < left_spaces; j++) cout << " ";
    cout << lines[i];
    for (int j = 0; j < right_spaces; j++) cout << " ";
    cout << "*" << endl;
  }
  cout << top_bot << endl;
  return 0;
}
