import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  }

} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  }

} Main public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  } main {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  } Scanner stdin = new Scanner(System.in); stdin new Scanner(System.in) while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    } true {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    } int H = stdin.nextInt(); H stdin.nextInt() stdin.nextInt stdin int W = stdin.nextInt(); W stdin.nextInt() stdin.nextInt stdin if (H == 0 && W == 0) {
        break;
      } H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
        break;
      } break; StringBuilder rect = new StringBuilder(); rect new StringBuilder() for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      } int i = 0; int i = 0; i 0 i < H i H i++ i++ i {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      } {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      } for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        } int j = 0; int j = 0; j 0 j < W j W j++ j++ j {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        } {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        } if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          } i == 0 || i == H - 1 || j == 0 || j == W - 1 j == 0 i == 0 || i == H - 1 || j == 0 || j == W - 1 i == 0 i 0 i == H - 1 i H - 1 H 1 j == 0 j 0 j == W - 1 j W - 1 W 1 {
            rect.append("#");
          } rect.append("#") rect.append rect "#" {
            rect.append(".");
          } rect.append(".") rect.append rect "." rect.append("\n") rect.append rect "\n" System.out.println(rect) System.out.println System.out System System.out rect String[] args args public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  }

} public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  }

} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
            rect.append("#");
          } else {
            rect.append(".");
          }
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  }

}