import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	}

} Main public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        } true {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        } String[] list = br.readLine().split(" "); list br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(list[1]); x Integer.parseInt(list[1]) Integer.parseInt Integer list[1] list 1 int y = Integer.parseInt(list[0]); y Integer.parseInt(list[0]) Integer.parseInt Integer list[0] list 0 if (x == 0 && y == 0)
            	break; x == 0 && y == 0 x == 0 x 0 y == 0 y 0 break; for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            } int i = 0; int i = 0; i 0 i < y i y i++ i++ i {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            } {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            } for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	} int j = 0; int j = 0; j 0 j < x j x j++ j++ j {
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	} {
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	} if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print("."); i == 0 || i == y - 1 || j == 0 || j == x - 1 j == 0 i == 0 || i == y - 1 || j == 0 || j == x - 1 i == 0 i 0 i == y - 1 i y - 1 y 1 j == 0 j 0 j == x - 1 j x - 1 x 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)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	}

} public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] list = br.readLine().split(" ");
        	int x = Integer.parseInt(list[1]);
            int y = Integer.parseInt(list[0]);
            if (x == 0 && y == 0)
            	break;
            for (int i = 0; i < y; i++)
            {
            	for (int j = 0; j < x; j++)
            	{
            		if (i == 0 || i == y - 1 || j == 0 || j == x - 1)
            			System.out.print("#");
            		else
            			System.out.print(".");
            	}
            	System.out.println("");
            }
            System.out.println("");
        }
        
	}

}