import java.io.*;
import java.util.Arrays;
class Main{
	public static void main(String[] args) throws IOException {
		int i,j;
		int[] n = new int[990];
		String[] str = new String[990];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util class Main{
	public static void main(String[] args) throws IOException {
		int i,j;
		int[] n = new int[990];
		String[] str = new String[990];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
} Main public static void main(String[] args) throws IOException {
		int i,j;
		int[] n = new int[990];
		String[] str = new String[990];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	} main {
		int i,j;
		int[] n = new int[990];
		String[] str = new String[990];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	} int i i j; j int[] n = new int[990]; n new int[990] 990 String[] str = new String[990]; str new String[990] 990 BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) for(;;){
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} ; {
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} {
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		} str = in.readLine().split(" ") str in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			} i=0; i=0 i 0 i<2 i 2 i++ i++ i {
				n[i] = Integer.parseInt(str[i]);
			} {
				n[i] = Integer.parseInt(str[i]);
			} n[i] = Integer.parseInt(str[i]) n[i] n i Integer.parseInt(str[i]) Integer.parseInt Integer str[i] str i if(n[0]+n[1]==0) break; n[0]+n[1]==0 n[0]+n[1] n[0] n 0 n[1] n 1 0 break; for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			} i=0; i=0 i 0 i<n[0] i n[0] n 0 i++ i++ i {
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			} {
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			} for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				} j=0; j=0 j 0 j<n[1] j n[1] n 1 j++ j++ j {
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				} {
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				} if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print("."); i==0 || i==n[0]-1 || j==0 || j==n[1]-1 j==0 i==0 || i==n[0]-1 || j==0 || j==n[1]-1 i==0 i 0 i==n[0]-1 i n[0]-1 n[0] n 0 1 j==0 j 0 j==n[1]-1 j n[1]-1 n[1] n 1 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
import java.io.*;
import java.util.Arrays;
class Main{
	public static void main(String[] args) throws IOException {
		int i,j;
		int[] n = new int[990];
		String[] str = new String[990];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			str = in.readLine().split(" ");
			for(i=0;i<2;i++){
				n[i] = Integer.parseInt(str[i]);
			}
			if(n[0]+n[1]==0) break;
			for(i=0;i<n[0];i++){
				for(j=0;j<n[1];j++){
					if(i==0 || i==n[0]-1 || j==0 || j==n[1]-1)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}