import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
public class Main{
    public static void main(String[] args) throws IOException {
        int xLine = 0;
        int yLine = 0;
        Boolean flg = true;
        
        BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb =
        		new StringBuilder();
        
        
        while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\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 {
        int xLine = 0;
        int yLine = 0;
        Boolean flg = true;
        
        BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb =
        		new StringBuilder();
        
        
        while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        	
        }
        System.out.print(sb);
    }
} Main public static void main(String[] args) throws IOException {
        int xLine = 0;
        int yLine = 0;
        Boolean flg = true;
        
        BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb =
        		new StringBuilder();
        
        
        while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        	
        }
        System.out.print(sb);
    } main {
        int xLine = 0;
        int yLine = 0;
        Boolean flg = true;
        
        BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb =
        		new StringBuilder();
        
        
        while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        	
        }
        System.out.print(sb);
    } int xLine = 0; xLine 0 int yLine = 0; yLine 0 Boolean flg = true; flg true BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb =
        		new StringBuilder(); sb new StringBuilder() while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        	
        } flg {
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        	
        } String str[] = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " yLine = Integer.parseInt(str[0]) yLine Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 xLine = Integer.parseInt(str[1]) xLine Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            } xLine==0 && yLine==0 xLine==0 xLine 0 yLine==0 yLine 0 {
        		flg = false;

        	} flg = false flg false {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            } for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                } int i=0; int i=0; i 0 i<yLine i yLine i++ i++ i {
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                } {
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                } for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    } int j=0; int j=0; j 0 j<xLine j xLine j++ j++ j {
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    } {
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    } if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		} j>=1 && i<yLine-1 && i>=1 && j<xLine-1 i>=1 j>=1 && i<yLine-1 && i>=1 && j<xLine-1 j>=1 j 1 i<yLine-1 i yLine-1 yLine 1 i>=1 i 1 j<xLine-1 j xLine-1 xLine 1 {
                    		sb.append(".");
                    		} sb.append(".") sb.append sb "." {
                    		sb.append("#");
                    		} sb.append("#") sb.append sb "#" 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 IOException {
        int xLine = 0;
        int yLine = 0;
        Boolean flg = true;
        
        BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb =
        		new StringBuilder();
        
        
        while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        	
        }
        System.out.print(sb);
    }
} public class Main{
    public static void main(String[] args) throws IOException {
        int xLine = 0;
        int yLine = 0;
        Boolean flg = true;
        
        BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb =
        		new StringBuilder();
        
        
        while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\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 {
        int xLine = 0;
        int yLine = 0;
        Boolean flg = true;
        
        BufferedReader br =
        		new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb =
        		new StringBuilder();
        
        
        while(flg){
            String str[] = br.readLine().split(" ");
            yLine = Integer.parseInt(str[0]);
            xLine = Integer.parseInt(str[1]);

            if(xLine==0 && yLine==0) {
        		flg = false;

        	}
        	else {

        		for(int i=0; i<yLine; i++){
        			for(int j=0; j<xLine; j++){
                    	if(j>=1 && i<yLine-1 && i>=1 && j<xLine-1 ){
                    		sb.append(".");
                    		}
                    	else {
                    		sb.append("#");
                    		}
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        	
        }
        System.out.print(sb);
    }
}