import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int W = scan.nextInt();
    while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    }
 
  }
} import java.util.Scanner; Scanner java.util public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int W = scan.nextInt();
    while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    }
 
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int W = scan.nextInt();
    while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    }
 
  } main {
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int W = scan.nextInt();
    while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    }
 
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int H = scan.nextInt(); H scan.nextInt() scan.nextInt scan int W = scan.nextInt(); W scan.nextInt() scan.nextInt scan while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    } H != 0 || W != 0 H != 0 H 0 W != 0 W 0 {
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    } StringBuilder sb2 = new StringBuilder(); sb2 new StringBuilder() for(int i=0;i<W; i++){
          sb2.append("#");} int i=0; int i=0; i 0 i<W i W i++ i++ i {
          sb2.append("#");} {
          sb2.append("#");} sb2.append("#") sb2.append sb2 "#" System.out.println(sb2) System.out.println System.out System System.out sb2 StringBuilder sb = new StringBuilder(); sb new StringBuilder() for(int i=0; i<W-2; i++ ){
        sb.append(".");
      } int i=0; int i=0; i 0 i<W-2 i W-2 W 2 i++ i++ i {
        sb.append(".");
      } {
        sb.append(".");
      } sb.append(".") sb.append sb "." for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      } int j=0; int j=0; j 0 j<H-2 j H-2 H 2 j++ j++ j {
        System.out.println("#" + sb + "#");
      } {
        System.out.println("#" + sb + "#");
      } System.out.println("#" + sb + "#") System.out.println System.out System System.out "#" + sb + "#" "#" + sb + "#" "#" sb "#" System.out.println(sb2) System.out.println System.out System System.out sb2 System.out.println("") System.out.println System.out System System.out "" H = scan.nextInt() H scan.nextInt() scan.nextInt scan W = scan.nextInt() W scan.nextInt() scan.nextInt scan String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int W = scan.nextInt();
    while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    }
 
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int W = scan.nextInt();
    while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    }
 
  }
} Main
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int W = scan.nextInt();
    while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    }
 
  }
}