//y???0???a-1

import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
        int a = 0;
        int b = 0;
        
            while(true){
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    }
        
        
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
    public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
        int a = 0;
        int b = 0;
        
            while(true){
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    }
        
        
    }
} Main public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
        int a = 0;
        int b = 0;
        
            while(true){
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    }
        
        
    } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
        int a = 0;
        int b = 0;
        
            while(true){
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    }
        
        
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int a = 0; a 0 int b = 0; b 0 while(true){
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    } true {
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    } StringTokenizer st = new StringTokenizer(br.readLine(), " "); st new StringTokenizer(br.readLine(), " ") b = Integer.parseInt(st.nextToken()) b Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st a = Integer.parseInt(st.nextToken()) a Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st if(a==0&&b==0)break; a==0&&b==0 a==0 a 0 b==0 b 0 break; for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        } int x = 0; int x = 0; x 0 x<b x b x++ x++ x {
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        } {
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        } for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            } int y = 0; int y = 0; y 0 y<a y a y++ y++ y {
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            } {
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            } if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                } y==0||y==a-1||x==0||x==b-1 x==0 y==0||y==a-1||x==0||x==b-1 y==0 y 0 y==a-1 y a-1 a 1 x==0 x 0 x==b-1 x b-1 b 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.print("\n") System.out.print System.out System System.out "\n" System.out.print("\n") System.out.print System.out System System.out "\n" String[] args args public class Main{
    public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
        int a = 0;
        int b = 0;
        
            while(true){
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    }
        
        
    }
} public class Main{
    public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
        int a = 0;
        int b = 0;
        
            while(true){
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    }
        
        
    }
} Main
//y???0???a-1

import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
        int a = 0;
        int b = 0;
        
            while(true){
                StringTokenizer st = new StringTokenizer(br.readLine(), " ");
                b = Integer.parseInt(st.nextToken());
                a = Integer.parseInt(st.nextToken());

                    if(a==0&&b==0)break;
                        for(int x = 0; x<b; x++){
                            
                
                            for(int y = 0; y<a; y++){
                                if(y==0||y==a-1||x==0||x==b-1){
                                    System.out.print("#");
                                }
                                else{
                                    System.out.print(".");
                                }
                                
                            }
                
                            System.out.print("\n");
                        }
            
                        System.out.print("\n");
            
                    }
        
        
    }
}