import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
        void doIt(){
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        }
    }
} import java.awt.AWTException; AWTException java.awt import java.awt.Robot; Robot java.awt import java.awt.event.InputEvent; InputEvent java.awt.event import java.awt.event.MouseEvent; MouseEvent java.awt.event import java.awt.geom.Point2D; Point2D java.awt.geom import java.awt.geom.Point2D.Double; Double java.awt.geom.Point2D import java.util.*; util.* java public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
        void doIt(){
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        }
    }
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        new Main(); 
    } main {
        new Main(); 
    } new Main() String[] args args public Main() {
        new TEST().doIt();
    } Main {
        new TEST().doIt();
    } new TEST().doIt() new TEST().doIt new TEST() class TEST{
        void doIt(){
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        }
    } TEST void doIt(){
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        } doIt {
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        } while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	} true {
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	} int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc if(n + m == 0)break; n + m == 0 n + m n m 0 break; for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		} {
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		} for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			} int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			} {
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			} if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print("."); i == 0 || j == 0 || i == (n-1) || j == (m-1) i == (n-1) i == 0 || j == 0 || i == (n-1) || j == (m-1) i == 0 i 0 j == 0 j 0 i == (n-1) i (n-1) n 1 j == (m-1) j (m-1) m 1 System.out.print("#") System.out.print System.out System System.out "#" System.out.print(".") System.out.print System.out System System.out "." System.out.println() System.out.println System.out System System.out System.out.println() System.out.println System.out System System.out public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
        void doIt(){
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        }
    }
} public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
        void doIt(){
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        }
    }
} Main
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
        void doIt(){
        	while(true){
        		int n = sc.nextInt();
        		int m = sc.nextInt();
        		if(n + m == 0)break;
        		for(int i = 0;i < n;i++){
        			for(int j = 0;j < m;j++){
        				if(i == 0 || j == 0 || i == (n-1) || j == (m-1))System.out.print("#");
        				else System.out.print(".");
        			}
        			System.out.println();
        		}
        		System.out.println();
        	}
        }
    }
}