import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int a,b,c,d,e;
		   a=1;b=1;e=1;
	       Scanner sc = new Scanner(System.in);
	       while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       }
		}

    } import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int a,b,c,d,e;
		   a=1;b=1;e=1;
	       Scanner sc = new Scanner(System.in);
	       while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       }
		}

    } Main public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int a,b,c,d,e;
		   a=1;b=1;e=1;
	       Scanner sc = new Scanner(System.in);
	       while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       }
		} main {
		// TODO ?????????????????????????????????????????????
		int a,b,c,d,e;
		   a=1;b=1;e=1;
	       Scanner sc = new Scanner(System.in);
	       while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       }
		} int a a b b c c d d e; e a=1 a 1 b=1 b 1 e=1 e 1 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       } a!=0 || b!=0 a!=0 a 0 b!=0 b 0 {
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       } a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc c = 1 c 1 d = 1 d 1 if (e != 1){
	    	   System.out.println();
	       } e != 1 e 1 {
	    	   System.out.println();
	       } System.out.println() System.out.println System.out System System.out while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       } c<=a c a {
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       } if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   } c==1||c==a c==1 c 1 c==a c a {
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   } while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   } d<=b d b {
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   } if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   } d!=b d b {
	    				   System.out.print("#");
	    			   } System.out.print("#") System.out.print System.out System System.out "#" {
	    				   System.out.println("#");
	    			   } System.out.println("#") System.out.println System.out System System.out "#" d=d+1 d d+1 d 1 {
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   } while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   } d<=b d b {
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   } if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   } d==1 d 1 {
	    			   System.out.print("#");
	    		   } System.out.print("#") System.out.print System.out System System.out "#" if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   } d==b d b {
	    			   System.out.println("#");
	    		   } System.out.println("#") System.out.println System.out System System.out "#" {
	    			   System.out.print(".");
	    		   } System.out.print(".") System.out.print System.out System System.out "." d = d+1 d d+1 d 1 c = c+1 c c+1 c 1 d = 1 d 1 e=e+1 e e+1 e 1 String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int a,b,c,d,e;
		   a=1;b=1;e=1;
	       Scanner sc = new Scanner(System.in);
	       while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       }
		}

    } public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int a,b,c,d,e;
		   a=1;b=1;e=1;
	       Scanner sc = new Scanner(System.in);
	       while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       }
		}

    } Main
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int a,b,c,d,e;
		   a=1;b=1;e=1;
	       Scanner sc = new Scanner(System.in);
	       while (a!=0 || b!=0){
	       a = sc.nextInt();
	       b = sc.nextInt();
	       c = 1;
	       d = 1;
	       if (e != 1){
	    	   System.out.println();
	       }
	       
	       while(c<=a){
	    	   
	    	   if(c==1||c==a){
	    		   
	    		   while(d<=b){
	    			   if(d!=b){
	    				   System.out.print("#");
	    			   }
	    			   else{
	    				   System.out.println("#");
	    			   }
	    		   d=d+1;
	    		   }
	    		   
	    	   }
	    	   
	    	   else{
	    		   
	    	   while(d<=b){
	    		   
	    		   if(d==1){
	    			   System.out.print("#");
	    		   }else if(d==b){
	    			   System.out.println("#");
	    		   }
	    		   else{
	    			   System.out.print(".");
	    		   }
	    		   
	    		   d = d+1;
	    	   }
	    	   
	    	   }
	    	   
	    	   c = c+1;
	    	   d = 1;
	       }
	       e=e+1;
	       }
		}

    }