import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	}} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	}} Main public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	} main {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) StringBuilder soto=new StringBuilder(""); soto new StringBuilder("") StringBuilder naka=new StringBuilder(""); naka new StringBuilder("") int H=sc.nextInt() H sc.nextInt() sc.nextInt sc W=sc.nextInt() W sc.nextInt() sc.nextInt sc x; x while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			} H!=0||W!=0 H!=0 H 0 W!=0 W 0 {
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			} x=0 x 0 for(int n=1;n<=W;n++){
			x++;
			soto.append("#");} int n=1; int n=1; n 1 n<=W n W n++ n++ n {
			x++;
			soto.append("#");} {
			x++;
			soto.append("#");} x++ x soto.append("#") soto.append soto "#" naka.append("#") naka.append naka "#" for(int n=1;n<=W-2;n++){
			naka.append(".");} int n=1; int n=1; n 1 n<=W-2 n W-2 W 2 n++ n++ n {
			naka.append(".");} {
			naka.append(".");} naka.append(".") naka.append naka "." naka.append("#") naka.append naka "#" System.out.println(soto) System.out.println System.out System System.out soto for(int n=1;n<=H-2;n++){
			System.out.println(naka);} int n=1; int n=1; n 1 n<=H-2 n H-2 H 2 n++ n++ n {
			System.out.println(naka);} {
			System.out.println(naka);} System.out.println(naka) System.out.println System.out System System.out naka System.out.println(soto) System.out.println System.out System System.out soto System.out.println() System.out.println System.out System System.out soto.delete(0,x) soto.delete soto 0 x naka.delete(0,x) naka.delete naka 0 x H=sc.nextInt() H sc.nextInt() sc.nextInt sc W=sc.nextInt() W sc.nextInt() sc.nextInt sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	}} public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	}} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	}}