import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sbu=new StringBuilder();
        
        while(true){
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        }
        System.out.print(sbu);
     }
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sbu=new StringBuilder();
        
        while(true){
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        }
        System.out.print(sbu);
     }
} Main public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sbu=new StringBuilder();
        
        while(true){
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        }
        System.out.print(sbu);
     } main {
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sbu=new StringBuilder();
        
        while(true){
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        }
        System.out.print(sbu);
     } BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); buf new BufferedReader(new InputStreamReader(System.in)) StringBuilder sbu=new StringBuilder(); sbu new StringBuilder() while(true){
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        } true {
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        } String[] num=buf.readLine().split(" "); num buf.readLine().split(" ") buf.readLine().split buf.readLine() buf.readLine buf " " int x=Integer.parseInt(num[0]); x Integer.parseInt(num[0]) Integer.parseInt Integer num[0] num 0 int y=Integer.parseInt(num[1]); y Integer.parseInt(num[1]) Integer.parseInt Integer num[1] num 1 if(x==0 && y==0)break; x==0 && y==0 x==0 x 0 y==0 y 0 break; for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            } int i=0; int i=0; i 0 i<x i x i++ i++ i {
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            } {
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            } for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                } int j=0; int j=0; j 0 j<y j y j++ j++ j {
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                } {
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                } if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append("."); j==0 || i==0 || j==y-1 || i==x-1 j==y-1 j==0 || i==0 || j==y-1 || i==x-1 j==0 j 0 i==0 i 0 j==y-1 j y-1 y 1 i==x-1 i x-1 x 1 sbu.append("#") sbu.append sbu "#" sbu.append(".") sbu.append sbu "." sbu.append("\n") sbu.append sbu "\n" sbu.append("\n") sbu.append sbu "\n" System.out.print(sbu) System.out.print System.out System System.out sbu String[] args args public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sbu=new StringBuilder();
        
        while(true){
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        }
        System.out.print(sbu);
     }
} public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sbu=new StringBuilder();
        
        while(true){
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        }
        System.out.print(sbu);
     }
} Main
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sbu=new StringBuilder();
        
        while(true){
            String[] num=buf.readLine().split(" ");
            int x=Integer.parseInt(num[0]);
            int y=Integer.parseInt(num[1]);
            
            if(x==0 && y==0)break;
            
            for(int i=0; i<x; i++){
                for(int j=0; j<y;j++){
                    if(j==0 || i==0 || j==y-1 || i==x-1)
                        sbu.append("#");
                    else
                    sbu.append(".");
                }
                sbu.append("\n");
            }
            sbu.append("\n");
        }
        System.out.print(sbu);
     }
}