import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        while(true){
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        }
        System.out.print(build);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        while(true){
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        }
        System.out.print(build);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        while(true){
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        }
        System.out.print(build);
    } main {
        Scanner input = new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        while(true){
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        }
        System.out.print(build);
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) StringBuilder build = new StringBuilder(); build new StringBuilder() while(true){
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        } true {
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        } int h = input.nextInt(); h input.nextInt() input.nextInt input int w = input.nextInt(); w input.nextInt() input.nextInt input if(h==0&&w==0){
                break;
            } h==0&&w==0 h==0 h 0 w==0 w 0 {
                break;
            } break; for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            } int n = 0; int n = 0; n 0 n < h n h n++ n++ n {
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            } {
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            } for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                } int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                } {
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                } if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    } (n == 0 || n == h-1)||(i==0 || i==w-1) (n == 0 || n == h-1) n == 0 n 0 n == h-1 n h-1 h 1 (i==0 || i==w-1) i==0 i 0 i==w-1 i w-1 w 1 {
                    build.append("#");
                    } build.append("#") build.append build "#" {
                    build.append(".");
                    } build.append(".") build.append build "." build.append("\n") build.append build "\n" build.append("\n") build.append build "\n" System.out.print(build) System.out.print System.out System System.out build String[] args args public class Main {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        while(true){
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        }
        System.out.print(build);
    }
} public class Main {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        while(true){
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        }
        System.out.print(build);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner input = new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        while(true){
            int h = input.nextInt();
            int w = input.nextInt();
            if(h==0&&w==0){
                break;
            }
            for(int n = 0; n < h; n++){
                for(int i = 0; i < w; i++){
                    if((n == 0 || n == h-1)||(i==0 || i==w-1)){
                    build.append("#");
                    }else{
                    build.append(".");
                    }
                }
                build.append("\n");
            }
             build.append("\n");
        }
        System.out.print(build);
    }
}