import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    while (true) {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      int last_h = h - 1;
      int last_w = w - 1;

      if (h == 0 && w == 0) break;

      String edge = "";
      String line = "";

      for (int j = 0; j < w; j++) {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      }

      for (int i = 0; i < h; i++) {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      }
      System.out.println();
    }

    scanner.close();
  }
} import java.util.Scanner; Scanner java.util class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    while (true) {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      int last_h = h - 1;
      int last_w = w - 1;

      if (h == 0 && w == 0) break;

      String edge = "";
      String line = "";

      for (int j = 0; j < w; j++) {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      }

      for (int i = 0; i < h; i++) {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      }
      System.out.println();
    }

    scanner.close();
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    while (true) {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      int last_h = h - 1;
      int last_w = w - 1;

      if (h == 0 && w == 0) break;

      String edge = "";
      String line = "";

      for (int j = 0; j < w; j++) {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      }

      for (int i = 0; i < h; i++) {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      }
      System.out.println();
    }

    scanner.close();
  } main {
    Scanner scanner = new Scanner(System.in);

    while (true) {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      int last_h = h - 1;
      int last_w = w - 1;

      if (h == 0 && w == 0) break;

      String edge = "";
      String line = "";

      for (int j = 0; j < w; j++) {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      }

      for (int i = 0; i < h; i++) {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      }
      System.out.println();
    }

    scanner.close();
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (true) {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      int last_h = h - 1;
      int last_w = w - 1;

      if (h == 0 && w == 0) break;

      String edge = "";
      String line = "";

      for (int j = 0; j < w; j++) {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      }

      for (int i = 0; i < h; i++) {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      }
      System.out.println();
    } true {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      int last_h = h - 1;
      int last_w = w - 1;

      if (h == 0 && w == 0) break;

      String edge = "";
      String line = "";

      for (int j = 0; j < w; j++) {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      }

      for (int i = 0; i < h; i++) {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      }
      System.out.println();
    } int h = scanner.nextInt(); h scanner.nextInt() scanner.nextInt scanner int w = scanner.nextInt(); w scanner.nextInt() scanner.nextInt scanner int last_h = h - 1; last_h h - 1 h 1 int last_w = w - 1; last_w w - 1 w 1 if (h == 0 && w == 0) break; h == 0 && w == 0 h == 0 h 0 w == 0 w 0 break; String edge = ""; edge "" String line = ""; line "" for (int j = 0; j < w; j++) {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      } int j = 0; int j = 0; j 0 j < w j w j++ j++ j {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      } {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      } edge += "#" edge "#" if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        } j == 0 || j == last_w j == 0 j 0 j == last_w j last_w {
          line += "#";
        } line += "#" line "#" {
          line += ".";
        } line += "." line "." for (int i = 0; i < h; i++) {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      } int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      } {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      } if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        } i == 0 || i == last_h i == 0 i 0 i == last_h i last_h {
          System.out.println(edge);
        } System.out.println(edge) System.out.println System.out System System.out edge {
          System.out.println(line);
        } System.out.println(line) System.out.println System.out System System.out line System.out.println() System.out.println System.out System System.out scanner.close() scanner.close scanner String[] args args
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    while (true) {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      int last_h = h - 1;
      int last_w = w - 1;

      if (h == 0 && w == 0) break;

      String edge = "";
      String line = "";

      for (int j = 0; j < w; j++) {
        edge += "#";
        if (j == 0 || j == last_w) {
          line += "#";
        } else {
          line += ".";
        }
      }

      for (int i = 0; i < h; i++) {
        if (i == 0 || i == last_h) {
          System.out.println(edge);
        } else {
          System.out.println(line);
        }
      }
      System.out.println();
    }

    scanner.close();
  }
}