import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        }

    }
} import java.io.*; io.* java public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        }

    }
} Main public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        }

    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        }

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        } true {
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        } String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int h = Integer.parseInt(str[0]); h Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int w = Integer.parseInt(str[1]); w Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 StringBuilder sb = new StringBuilder(); sb new StringBuilder() if( h == 0 && w == 0)break; h == 0 && w == 0 h == 0 h 0 w == 0 w 0 break; for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            } int i=0; int i=0; i 0 i<h i h i++ i++ i {
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            } {
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            } if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                } i==0 || i==h-1 i==0 i 0 i==h-1 i h-1 h 1 {
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                } for(int k=0; k<w; k++){
                        sb.append("#");
                    } int k=0; int k=0; k 0 k<w k w k++ k++ k {
                        sb.append("#");
                    } {
                        sb.append("#");
                    } sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" {
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                } for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    } int k=0; int k=0; k 0 k<w k w k++ k++ k {
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    } {
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    } if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        } k==0 || k==w-1 k==0 k 0 k==w-1 k w-1 w 1 {
                            sb.append("#");
                        } sb.append("#") sb.append sb "#" {
                            sb.append(".");
                        } sb.append(".") sb.append sb "." sb.append("\n") sb.append sb "\n" System.out.println(sb) System.out.println System.out System System.out sb String[]args args public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        }

    }
} public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        }

    }
} Main
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true){
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            StringBuilder sb = new StringBuilder();

            if( h == 0 && w == 0)break;
            for(int i=0; i<h; i++){
                if(i==0 || i==h-1){
                    for(int k=0; k<w; k++){
                        sb.append("#");
                    }
                    sb.append("\n");
                }else{
                    for(int k=0; k<w; k++){
                        if(k==0 || k==w-1){
                            sb.append("#");
                        }else{
                            sb.append(".");
                        }
                    }
                    sb.append("\n");
                }
            }
            System.out.println(sb);
        }

    }
}