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

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

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

public class Main {
    public static void main (String[] args ) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        
        while(true) {
            String line = reader.readLine();
            String[] column = line.split(" ");
            int y = Integer.parseInt(column[0]);
            int x = Integer.parseInt(column[1]);
            
            if ( y == 0 && x == 0 ) {
                break;
            }
            builder.append(StringUtilsRepeat(x,y));
        }
        System.out.print(builder);
    }
    public static StringBuilder StringUtilsRepeat(int x,int y) {
        StringBuilder line = new StringBuilder();
        String str = "#";
        String strin = ".";
        for ( int j = 1; j <= y; j++ ){
             for ( int i = 1; i <= x ; i++ ) {
                 if (j == 1 || j == y)
                     line.append(str);
                 else if (i == 1 || i == x)
                     line.append(str);
                 else
                     line.append(strin);
             }
             line.append("\n");
        }
        line.append("\n");
        return line;
    }
}