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();
	while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		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();
	while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		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();
	while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		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();
	while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		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 while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		H=sc.nextInt();W=sc.nextInt();
			} H!=0||W!=0 H!=0 H 0 W!=0 W 0 {
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		H=sc.nextInt();W=sc.nextInt();
			} soto.append("##") soto.append soto "##" naka.append("#") naka.append naka "#" for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.append("#");} int n=1; int n=1; n 1 n<=W-2 n W-2 W 2 n++ n++ n {
			naka.append(".");
			soto.append("#");} {
			naka.append(".");
			soto.append("#");} naka.append(".") naka.append naka "." soto.append("#") soto.append soto "#" 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,W) soto.delete soto 0 W naka.delete(0,W) naka.delete naka 0 W 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();
	while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		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();
	while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		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();
	while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.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,W);naka.delete(0,W);
		H=sc.nextInt();W=sc.nextInt();
			}
	}}