/* ITP1_5_B */
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while(true){
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height < 3 && width > 100) break;
      //draw
      for(int i = 0; i < height; i++){ //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
} import java.io.*; io.* java class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while(true){
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height < 3 && width > 100) break;
      //draw
      for(int i = 0; i < height; i++){ //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
} Main public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while(true){
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height < 3 && width > 100) break;
      //draw
      for(int i = 0; i < height; i++){ //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while(true){
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height < 3 && width > 100) break;
      //draw
      for(int i = 0; i < height; i++){ //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height < 3 && width > 100) break;
      //draw
      for(int i = 0; i < height; i++){ //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    } true {
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height < 3 && width > 100) break;
      //draw
      for(int i = 0; i < height; i++){ //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    } String str[] = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int height = Integer.parseInt(str[0]); height Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int width = Integer.parseInt(str[1]); width Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(height == 0 && width == 0) break; height == 0 && width == 0 height == 0 height 0 width == 0 width 0 break; if(height < 3 && width > 100) break; height < 3 && width > 100 height < 3 height 3 width > 100 width 100 break; for(int i = 0; i < height; i++){ //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      } int i = 0; int i = 0; i 0 i < height i height i++ i++ i { //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      } { //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      } for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        } int j = 0; int j = 0; j 0 j < width j width j++ j++ j { //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        } { //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        } if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          } i == 0 || i == height-1 i == 0 i 0 i == height-1 i height-1 height 1 {
            System.out.print("#");

          } System.out.print("#") System.out.print System.out System System.out "#" {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          } if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print("."); j == 0 || j== width-1 j == 0 j 0 j== width-1 j width-1 width 1 System.out.print("#") System.out.print System.out System System.out "#" 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
/* ITP1_5_B */
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    while(true){
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height < 3 && width > 100) break;
      //draw
      for(int i = 0; i < height; i++){ //height

        for(int j = 0; j < width; j++){ //width

          if(i == 0 || i == height-1){
            System.out.print("#");

          }else {
            if(j == 0 || j== width-1)
              System.out.print("#");
            else
              System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
}