import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	}
        System.out.print(sb);
    }

} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	}
        System.out.print(sb);
    }

} Main public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	}
        System.out.print(sb);
    } main {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	}
        System.out.print(sb);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	} true {
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	} int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc if(a==0&&b==0){
    			break;
    		} a==0&&b==0 a==0 a 0 b==0 b 0 {
    			break;
    		} break; for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		} int i=1; int i=1; i 1 i<=a i a i++ i++ i {
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		} {
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		} for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			} int x=1; int x=1; x 1 x<=b x b x++ x++ x {
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			} {
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			} if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     } i==1||i==a i==1 i 1 i==a i a {
    					 sb.append("#");
    				 } sb.append("#") sb.append sb "#" {
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     } if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    } x==1||x==b x==1 x 1 x==b x b {
    					    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 {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    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 {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	}
        System.out.print(sb);
    }

} Main
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	while(true){
    		int a = sc.nextInt();
    		int b = sc.nextInt();
    		if(a==0&&b==0){
    			break;
    		}

    		for(int i=1;i<=a;i++){
    			for(int x=1;x<=b;x++){
    				 if(i==1||i==a){
    					 sb.append("#");
    				 }
    			     else{
    				    if(x==1||x==b){
    					    sb.append("#");
    				    }else{
    				        sb.append(".");
    				    }
    			     }
    			}
    			sb.append("\n");
    		}
    		sb.append("\n");
    	}
        System.out.print(sb);
    }

}