import java.io.PrintWriter;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args){
        while(true){
            final int h = Integer.parseInt(sc.next());
            final int w = Integer.parseInt(sc.next());
            if(h==0||w==0) break;
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            }
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            out.println();
        }
        out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args){
        while(true){
            final int h = Integer.parseInt(sc.next());
            final int w = Integer.parseInt(sc.next());
            if(h==0||w==0) break;
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            }
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            out.println();
        }
        out.flush();
    }
} Main private static final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) private static final PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) public static void main(String[] Args){
        while(true){
            final int h = Integer.parseInt(sc.next());
            final int w = Integer.parseInt(sc.next());
            if(h==0||w==0) break;
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            }
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            out.println();
        }
        out.flush();
    } main {
        while(true){
            final int h = Integer.parseInt(sc.next());
            final int w = Integer.parseInt(sc.next());
            if(h==0||w==0) break;
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            }
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            out.println();
        }
        out.flush();
    } while(true){
            final int h = Integer.parseInt(sc.next());
            final int w = Integer.parseInt(sc.next());
            if(h==0||w==0) break;
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            }
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            out.println();
        } true {
            final int h = Integer.parseInt(sc.next());
            final int w = Integer.parseInt(sc.next());
            if(h==0||w==0) break;
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            }
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            out.println();
        } final int h = Integer.parseInt(sc.next()); h Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc final int w = Integer.parseInt(sc.next()); w Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if(h==0||w==0) break; h==0||w==0 h==0 h 0 w==0 w 0 break; for(int i = 0; i<w; i++)
                out.print('#'); int i = 0; int i = 0; i 0 i<w i w i++ i++ i out.print('#'); out.print('#') out.print out '#' out.println() out.println out for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            } int i = 1; int i = 1; i 1 i<h-1 i h-1 h 1 i++ i++ i {
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            } {
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            } out.print('#') out.print out '#' for(int j = 1; j<w-1; j++){
                    out.print('.');
                } int j = 1; int j = 1; j 1 j<w-1 j w-1 w 1 j++ j++ j {
                    out.print('.');
                } {
                    out.print('.');
                } out.print('.') out.print out '.' out.println('#') out.println out '#' for(int i = 0; i<w; i++)
                out.print('#'); int i = 0; int i = 0; i 0 i<w i w i++ i++ i out.print('#'); out.print('#') out.print out '#' out.println() out.println out out.println() out.println out out.flush() out.flush out String[] Args Args
import java.io.PrintWriter;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args){
        while(true){
            final int h = Integer.parseInt(sc.next());
            final int w = Integer.parseInt(sc.next());
            if(h==0||w==0) break;
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            }
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            out.println();
        }
        out.flush();
    }
}