import Control.Applicative
import Data.List

frame :: Int -> Int -> String
frame h w = (recUpper w) ++ (recInner w (h-2)) ++ (recUpper w)

recUpper :: Int -> String
recUpper w = (replicate w '#') ++ "\n"

recInner :: Int -> Int -> String
recInner w 0 = ""
recInner w h = "#" ++ (replicate (w-2) '.') ++ "#\n" ++ (recInner w (h-1))

main = do
{
    l <- map (map (read::String->Int) . words) . init . lines <$> getContents;
    let{
        sqs = [ frame (x!!0) (x!!1)  | x<-l ];
    };
    mapM_ putStrLn $ sqs;
}