import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        while(true){
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            }
        System.out.print(sb);
    }
 
} 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 input = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        while(true){
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            }
        System.out.print(sb);
    }
 
} Main public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        while(true){
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            }
        System.out.print(sb);
    } main {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        while(true){
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            }
        System.out.print(sb);
    } BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            } true {
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            } String line = input.readLine(); line input.readLine() input.readLine input String [] num = line.split(" "); num line.split(" ") line.split line " " int tate = Integer.parseInt(num[0]); tate Integer.parseInt(num[0]) Integer.parseInt Integer num[0] num 0 int yoko = Integer.parseInt(num[1]); yoko Integer.parseInt(num[1]) Integer.parseInt Integer num[1] num 1 if(tate == 0 && yoko == 0) break; tate == 0 && yoko == 0 tate == 0 tate 0 yoko == 0 yoko 0 break; for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            } int i = 0 ; int i = 0 ; i 0 i < yoko i yoko i++ i++ i {
                sb.append("#");
            } {
                sb.append("#");
            } sb.append("#") sb.append sb "#" sb.append("\n") sb.append sb "\n" for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            } int j = 0 ; int j = 0 ; j 0 j < tate-2 j tate-2 tate 2 j++ j++ j {
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            } {
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            } sb.append("#") sb.append sb "#" for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                } int k = 0 ; int k = 0 ; k 0 k < yoko-2 k yoko-2 yoko 2 k++ k++ k {
                    sb.append(".");
                } {
                    sb.append(".");
                } sb.append(".") sb.append sb "." sb.append("#\n") sb.append sb "#\n" for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            } int l = 0 ; int l = 0 ; l 0 l < yoko l yoko l++ l++ l {
                sb.append("#");
            } {
                sb.append("#");
            } sb.append("#") sb.append sb "#" sb.append("\n\n") sb.append sb "\n\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        while(true){
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            }
        System.out.print(sb);
    }
 
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        while(true){
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            }
        System.out.print(sb);
    }
 
} 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 input = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
 
        while(true){
            String line = input.readLine();
            String [] num = line.split(" ");
            int tate = Integer.parseInt(num[0]);
            int yoko = Integer.parseInt(num[1]);
 
            if(tate == 0 && yoko == 0) break;
 
            for(int i = 0 ; i < yoko ; i++){
                sb.append("#");
            }
            sb.append("\n");
            for(int j = 0 ; j < tate-2 ; j++){
                sb.append("#");
                for(int k = 0 ; k < yoko-2 ; k++){
                    sb.append(".");
                }
                sb.append("#\n");
            }
            for(int l = 0 ; l < yoko ; l++){
                sb.append("#");
            }
 
            sb.append("\n\n");
            }
        System.out.print(sb);
    }
 
}