import Control.Applicative

main = do hws <- (map read) . (concatMap words) . lines <$> getContents
          putStr . unlines $ map unlines (solve hws)

solve :: [Int] -> [[String]]
solve (h:w:res) | h == 0 && w == 0 = []
                | otherwise = makeFrame h w : solve res

makeFrame :: Int -> Int -> [String]
makeFrame h w = sand fr . replicate (h-2) . concat . sand "#" $ replicate (w-2) "."
                where fr = concat $ replicate w "#"

sand :: a -> [a] -> [a]
sand ele xs = reverse ( ele : (reverse $ ele : xs)) 