// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii,
       std.typecons;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {}
  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int w, h;
  dchar c;
  cin.scan(w, h, c);
 
  writeln("+" ~ "-".repeat(w - 2).join ~ "+");
  foreach (i; 0 .. h - 2) {
    if (i == (h - 2) / 2) {
      writeln("|" ~ ".".repeat((w - 2) / 2).join ~ cast(char)c ~ ".".repeat((w - 2) / 2).join ~ "|");
    } else {
      writeln("|" ~ ".".repeat(w - 2).join ~ "|");
    }
  }
  writeln("+" ~ "-".repeat(w - 2).join ~ "+");
}

