#include <bits/stdc++.h>
using namespace std;
int main() {
  string input[1001];
  long long i = 0, max_w = 0, lines = 0;
  while (getline(cin, input[lines])) {
    long long w = input[lines].length();
    max_w = max(w, max_w);
    lines++;
  }
  for (long long i = 0; i < max_w + 2; i++) printf("*");
  cout << "\n";
  long long is_left = 0;
  for (long long i = 0; i < lines; i++) {
    cout << "*";
    if (max_w & 1) {
      long long cur_len = input[i].length();
      if (cur_len & 1) {
        long long space = max_w / 2 - cur_len / 2;
        for (long long j = 0; j < space; j++) cout << " ";
        cout << input[i];
        for (long long j = 0; j < space; j++) cout << " ";
      } else {
        long long space = max_w / 2 - cur_len / 2;
        if (!is_left) {
          for (long long j = 0; j < space; j++) cout << " ";
          cout << input[i];
          for (long long j = 0; j < space + 1; j++) cout << " ";
          is_left = 1;
        } else {
          for (long long j = 0; j < space + 1; j++) cout << " ";
          cout << input[i];
          for (long long j = 0; j < space; j++) cout << " ";
          is_left = 0;
        }
      }
    } else {
      long long cur_len = input[i].length();
      if (!(cur_len & 1)) {
        long long space = max_w / 2 - cur_len / 2;
        for (long long j = 0; j < space; j++) cout << " ";
        cout << input[i];
        for (long long j = 0; j < space; j++) cout << " ";
      } else {
        long long space = max_w / 2 - cur_len / 2;
        if (!is_left) {
          for (long long j = 0; j < space - 1; j++) cout << " ";
          cout << input[i];
          for (long long j = 0; j < space; j++) cout << " ";
          is_left = 1;
        } else {
          for (long long j = 0; j < space; j++) cout << " ";
          cout << input[i];
          for (long long j = 0; j < space - 1; j++) cout << " ";
          is_left = 0;
        }
      }
    }
    cout << "*\n";
  }
  for (long long i = 0; i < max_w + 2; i++) printf("*");
  return 0;
}
