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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String symbol = "#";
        String dot = ".";
        
        while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        
        System.out.print(sb);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String symbol = "#";
        String dot = ".";
        
        while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        
        System.out.print(sb);
    }
} Main public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String symbol = "#";
        String dot = ".";
        
        while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        
        System.out.print(sb);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String symbol = "#";
        String dot = ".";
        
        while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        
        System.out.print(sb);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() String symbol = "#"; symbol "#" String dot = "."; dot "." while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        } true {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        } String[] ary = br.readLine().split(" "); ary br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int numH = Integer.parseInt(ary[0]); numH Integer.parseInt(ary[0]) Integer.parseInt Integer ary[0] ary 0 int numW = Integer.parseInt(ary[1]); numW Integer.parseInt(ary[1]) Integer.parseInt Integer ary[1] ary 1 if(numH == 0 && numW == 0){
                break;
            } numH == 0 && numW == 0 numH == 0 numH 0 numW == 0 numW 0 {
                break;
            } break; for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            } int i = 0; int i = 0; i 0 i < numH i numH i++ i++ i {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            } {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            } for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                } int j = 0; int j = 0; j 0 j < numW j numW j++ j++ j {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                } {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                } if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    } i == 0 || i == (numH - 1) i == 0 i 0 i == (numH - 1) i (numH - 1) numH 1 {
                        sb.append(symbol);
                    } sb.append(symbol) sb.append sb symbol if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    } j == 0 || j == (numW - 1) j == 0 j 0 j == (numW - 1) j (numW - 1) numW 1 {
                        sb.append(symbol);
                    } sb.append(symbol) sb.append sb symbol if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    } numW > 2 && numH > 2 numW > 2 numW 2 numH > 2 numH 2 {
                        sb.append(dot);
                    } sb.append(dot) sb.append sb dot {
                        sb.append(symbol);
                    } sb.append(symbol) sb.append sb symbol sb.append("\n") sb.append sb "\n" sb.append("\n") sb.append sb "\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 Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String symbol = "#";
        String dot = ".";
        
        while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        
        System.out.print(sb);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String symbol = "#";
        String dot = ".";
        
        while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        
        System.out.print(sb);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String symbol = "#";
        String dot = ".";
        
        while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            for (int i = 0; i < numH; i++) {
                for (int j = 0; j < numW; j++) {
                    if (i == 0 || i == (numH - 1)) {
                        sb.append(symbol);
                    } else if (j == 0 || j == (numW - 1)) {
                        sb.append(symbol);
                    } else if (numW > 2 && numH > 2){
                        sb.append(dot);
                    } else {
                        sb.append(symbol);
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        
        System.out.print(sb);
    }
}