import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			int h=s.nextInt(),
			    w=s.nextInt();
			if((h|w)==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
} import java.util.*; util.* java class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			int h=s.nextInt(),
			    w=s.nextInt();
			if((h|w)==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
} Main static Scanner s = new Scanner(System.in); s new Scanner(System.in) public static void main(String[] args){
		while(true){
			int h=s.nextInt(),
			    w=s.nextInt();
			if((h|w)==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			}
			System.out.println();
		}
	} main {
		while(true){
			int h=s.nextInt(),
			    w=s.nextInt();
			if((h|w)==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			}
			System.out.println();
		}
	} while(true){
			int h=s.nextInt(),
			    w=s.nextInt();
			if((h|w)==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			}
			System.out.println();
		} true {
			int h=s.nextInt(),
			    w=s.nextInt();
			if((h|w)==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			}
			System.out.println();
		} int h=s.nextInt() h s.nextInt() s.nextInt s w=s.nextInt(); w s.nextInt() s.nextInt s if((h|w)==0)
				break; (h|w)==0 (h|w) h w 0 break; for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			} int i=0; int i=0; i 0 i<h i h i++ i++ i {
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			} {
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			} for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				} int j=0; int j=0; j 0 j<w j w j++ j++ j {
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				} {
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				} System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".") System.out.print System.out System System.out (i==0||i==h-1||j==0||j==w-1)?"#":"." (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 "#" "." 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
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			int h=s.nextInt(),
			    w=s.nextInt();
			if((h|w)==0)
				break;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					System.out.print((i==0||i==h-1||j==0||j==w-1)?"#":".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}