#include <bits/stdc++.h>
using namespace std;
int main() {
  int left = 1, right = 0;
  vector<string> v;
  vector<int> vec;
  string s;
  while (getline(cin, s)) {
    v.push_back(s);
  }
  int maxx = 0;
  for (int i = 0; i < v.size(); i++) vec.push_back(v[i].length());
  for (int i = 0; i < v.size(); i++) maxx = max(maxx, vec[i]);
  for (int i = 0; i <= v.size() + 1; i++) {
    if (i == 0 || i == v.size() + 1) {
      for (int j = 0; j < maxx + 2; j++) cout << "*";
    } else if (maxx % 2 == 0) {
      cout << "*";
      if (vec[i - 1] % 2 == 0) {
        for (int j = 0; j < ((maxx - vec[i - 1]) / 2); j++) cout << " ";
        cout << v[i - 1];
        for (int j = 0; j < ((maxx - vec[i - 1]) / 2); j++) cout << " ";
      } else {
        if (left > right) {
          for (int j = 0; j < ((maxx - vec[i - 1]) / 2); j++) cout << " ";
          cout << v[i - 1];
          for (int j = 0; j <= ((maxx - vec[i - 1]) / 2); j++) cout << " ";
          left--;
          right++;
        } else {
          for (int j = 0; j <= ((maxx - vec[i - 1]) / 2); j++) cout << " ";
          cout << v[i - 1];
          for (int j = 0; j < ((maxx - vec[i - 1]) / 2); j++) cout << " ";
          left++;
          right--;
        }
      }
      cout << "*";
    } else {
      cout << "*";
      if (vec[i - 1] % 2 == 1) {
        for (int j = 0; j < ((maxx - vec[i - 1]) / 2); j++) cout << " ";
        cout << v[i - 1];
        for (int j = 0; j < ((maxx - vec[i - 1]) / 2); j++) cout << " ";
      } else {
        if (left > right) {
          for (int j = 0; j < ((maxx - vec[i - 1]) / 2); j++) cout << " ";
          cout << v[i - 1];
          for (int j = 0; j <= ((maxx - vec[i - 1]) / 2); j++) cout << " ";
          left--;
          right++;
        } else {
          for (int j = 0; j <= ((maxx - vec[i - 1]) / 2); j++) cout << " ";
          cout << v[i - 1];
          for (int j = 0; j < ((maxx - vec[i - 1]) / 2); j++) cout << " ";
          left++;
          right--;
        }
      }
      cout << "*";
    }
    cout << endl;
  }
  return 0;
}
