import Control.Applicative

type Problem = (Int, Int)
type Result = [String]

slove :: Problem -> Result
slove (h, w) = (replicate 1 (paintLine w)) ++ (replicate (h - 2) (paintRoom w)) ++ (replicate 1 (paintLine w))

paintLine :: Int -> String
paintLine w = concat . replicate w $ "#"

paintRoom :: Int -> String
paintRoom w = "#" ++ (concat.replicate (w - 2) $ ".") ++ "#"  

input :: IO Problem
input = do 
        [h, w] <- map (read :: String -> Int).words <$> getLine
        return (h, w)

output :: Result -> IO ()
output xs = putStrLn $ concat [x ++ "\n" | x <- xs]

main :: IO ()
main = do 
         xs <- input
         if (xs == (0,0))
           then return ()
           else do
            output $ slove xs
            main