import java.util.Scanner;
public class Main
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
} import java.util.Scanner; Scanner java.util public class Main
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
} Main public static void main( String args[] )
	{
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	} main {
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) int h h w; w while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		} true {
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		} h=input.nextInt() h input.nextInt() input.nextInt input w=input.nextInt() w input.nextInt() input.nextInt input if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			} h == 0 && w == 0 h == 0 h 0 w == 0 w 0 break; {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			} for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				} int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				} {
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				} for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					} int k = 0; int k = 0; k 0 k < w k w k++ k++ k {
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					} {
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					} if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print("."); i == 0 || i == h-1 || k == 0 || k == w-1 k == 0 i == 0 || i == h-1 || k == 0 || k == w-1 i == 0 i 0 i == h-1 i h-1 h 1 k == 0 k 0 k == w-1 k w-1 w 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 String args[] args public class Main
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
} public class Main
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
} Main
import java.util.Scanner;
public class Main
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						if(i == 0 || i == h-1 || k == 0 || k == w-1)
							System.out.print("#");
						else
							System.out.print(".");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
}