using System;



class Program
{
    static void Main(string[] args)
    {
        Input CInput = new Input();
        //double input = 0;
        //int[] input = new int[(int)Input.Define.MAX_ArraySize];
        int[,] input = new int[(int)Input.Define.MAX_ArraySize, (int)Input.Define.ArraySize2d];
        int num = 0;
        //input = CInput.Line1_double();
        input = CInput.Multiline_int(' ', 2, ref num);


        for (int i = 0; i < 999999999; i++)
        {
            if (input[i, 0] == 0 && input[i, 1] == 0) break;
            for (int k = 0; k < input[i, 0]; k++)
            {
                for (int j = 0; j < input[i, 1]; j++)
                {
                    if (k == 0 || k == input[i, 0] - 1) Console.Write("#");
                    else if (j == 0 || j == input[i, 1] - 1) Console.Write("#");
                    else Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }








    class Input
    {
        public enum Define
        {
            MAX_ArraySize = 1000000,
            ArraySize2d = 2,                // 2?¬?????????????[][?] ???????
        }

        public string Line1_string()
        {
            return Console.ReadLine();
        }

        public int Line1_int()
        {
            var input = Console.ReadLine();
            return int.Parse(input);
        }

        public double Line1_double()
        {
            var input = Console.ReadLine();
            return double.Parse(input);
        }

        public int[] Line1_int(int chr, int num)
        {
            var input = Console.ReadLine();
            var split = input.Split(' ');
            int[] spliti = new int[100];
            for (int i = 0; i < num; i++)
            {
                spliti[i] = int.Parse(split[i]);
            }
            return spliti;
        }

        public int[] Multiline_int(ref int datanum)
        {
            int i = 0;
            int[] data = new int[(int)Input.Define.MAX_ArraySize];
            while (true)
            {
                var input = Console.ReadLine();
                var value = int.Parse(input);
                if (value == 0) break;
                data[i] = value;
                i++;
            }
            datanum = i;
            return data;
        }
        /// <summary>
        /// ?????°??????int??????????????????????????????
        /// </summary>
        /// <param name="chr">???????????????</param>
        /// <param name="num">?????????????????????????????°</param>
        /// <param name="datanum">??????????????????????????°</param>
        /// <returns></returns>
        public int[,] Multiline_int(int chr, int num, ref int datanum)
        {
            int i = 0;
            int[,] data = new int[(int)Input.Define.MAX_ArraySize, (int)Input.Define.ArraySize2d];
            while (true)
            {
                var input = Console.ReadLine();
                var split = input.Split(' ');
                int[] spliti = new int[100];
                for (int j = 0; j < num; j++)
                {
                    spliti[j] = int.Parse(split[j]);
                }
                if (spliti[0] == 0 && spliti[1] == 0) break;
                data[i, 0] = spliti[0];
                data[i, 1] = spliti[1];
                i++;
            }
            datanum = i;
            return data;
        }

    }
}

Measured memory_bytes: 24420