import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        }
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        }
    } main {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        } int i = 0; int i = 0; i 0 i < 300 i 300 i++ i++ i {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        } {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        } String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc String[] l = line.split(" "); l line.split(" ") line.split line " " int H = Integer.parseInt(l[0]); H Integer.parseInt(l[0]) Integer.parseInt Integer l[0] l 0 int W = Integer.parseInt(l[1]); W Integer.parseInt(l[1]) Integer.parseInt Integer l[1] l 1 if(H == 0 && W == 0) {
            break;
          } H == 0 && W == 0 H == 0 H 0 W == 0 W 0 {
            break;
          } break; for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          } int h = 0; int h = 0; h 0 h < H h H h++ h++ h {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          } {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          } for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            } int w = 0; int w = 0; w 0 w < W w W w++ w++ w {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            } {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            } if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              } h == 0 || h == H -1 || w == 0 || w == W - 1 w == 0 h == 0 || h == H -1 || w == 0 || w == W - 1 h == 0 h 0 h == H -1 h H -1 H 1 w == 0 w 0 w == W - 1 w W - 1 W 1 {
                System.out.print("#");
              } System.out.print("#") System.out.print System.out System System.out "#" {
                System.out.print(".");
              } System.out.print(".") System.out.print System.out System System.out "." System.out.println() System.out.println System.out System System.out System.out.println() System.out.println System.out System System.out String[] args args public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        }
    }
} public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        }
    }
}