drawFrame :: Int -> Int -> String
drawFrame h w = replicate w '#' ++ "\n" ++
                (concat . replicate (h-2) $ "#" ++ replicate (w-2) '.' ++ "#\n") ++
                replicate w '#' ++ "\n"
main = getLine >>= \l -> let (h:w:_) = map read . words $ l
                         in if h == 0 && w == 0 then return ()
                            else do
                              putStrLn $ drawFrame h w
                              main