import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

        String line = br.readLine();

        while(!(line.equals("0 0"))){
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        }

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

        String line = br.readLine();

        while(!(line.equals("0 0"))){
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        }

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

        String line = br.readLine();

        while(!(line.equals("0 0"))){
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        }

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

        String line = br.readLine();

        while(!(line.equals("0 0"))){
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        }

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = br.readLine(); line br.readLine() br.readLine br while(!(line.equals("0 0"))){
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        } !(line.equals("0 0")) (line.equals("0 0")) line.equals line "0 0" {
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        } String[] inputs = line.split(" "); inputs line.split(" ") line.split line " " int height = Integer.valueOf(inputs[0]); height Integer.valueOf(inputs[0]) Integer.valueOf Integer inputs[0] inputs 0 int width = Integer.valueOf(inputs[1]); width Integer.valueOf(inputs[1]) Integer.valueOf Integer inputs[1] inputs 1 StringBuilder result = new StringBuilder(); result new StringBuilder() for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            } int i = 0; int i = 0; i 0 i < height i height i++ i++ i {
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            } {
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            } if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                } i == 0 || i == height-1 i == 0 i 0 i == height-1 i height-1 height 1 {
                    for(int j = 0; j < width; j++) result.append("#");
                } for(int j = 0; j < width; j++) result.append("#"); int j = 0; int j = 0; j 0 j < width j width j++ j++ j result.append("#"); result.append("#") result.append result "#" {
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                } for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    } int j = 0; int j = 0; j 0 j < width j width j++ j++ j {
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    } {
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    } if(j == 0 || j == width-1) result.append("#");
                        else result.append("."); j == 0 || j == width-1 j == 0 j 0 j == width-1 j width-1 width 1 result.append("#") result.append result "#" result.append(".") result.append result "." result.append("\n") result.append result "\n" System.out.println(result) System.out.println System.out System System.out result line = br.readLine() line br.readLine() br.readLine br String[] args args public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line = br.readLine();

        while(!(line.equals("0 0"))){
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        }

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

        String line = br.readLine();

        while(!(line.equals("0 0"))){
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        }

    }
} Main
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

        String line = br.readLine();

        while(!(line.equals("0 0"))){
            String[] inputs = line.split(" ");
            int height = Integer.valueOf(inputs[0]);
            int width = Integer.valueOf(inputs[1]);
            StringBuilder result = new StringBuilder();

            for(int i = 0; i < height; i++){
                if(i == 0 || i == height-1){
                    for(int j = 0; j < width; j++) result.append("#");
                }else{
                    for(int j = 0; j < width; j++){
                        if(j == 0 || j == width-1) result.append("#");
                        else result.append(".");
                    }
                }
                result.append("\n");
            }

            System.out.println(result);
            
            line = br.readLine();
        }

    }
}