import Data.Array.ST (STUArray, runSTUArray, newArray, writeArray, getBounds)
import Data.Array.Unboxed
import Data.Ix (range)
import Control.Monad.ST (ST,runST)
import Control.Monad
import Control.Applicative

type PosXY = (Int,Int) 
type Box = UArray PosXY Char
type STBox s = ST s (STUArray s PosXY Char)

mkBox :: Int -> Int -> Box
mkBox w h =
    let dirs = [(1,0), (0,1), (-1,0), (0,-1)] in
    runSTUArray $ do
        box <- newArray ((1,1),(w,h)) '.' :: STBox s 
        go box (1,1) dirs
    where
    go :: (STUArray s PosXY Char) -> PosXY -> [PosXY] -> STBox s 
    go box _ [] = return box
    go box xy dxdys@(dxy:nextdxys) = do
        rng <- getBounds box
        writeArray box xy '#' 
        let nxy = (\(x1,y1) (x2,y2) -> (x1+x2, y1+y2)) xy dxy
        if (inRange rng nxy) then
            go box nxy dxdys
        else
            go box xy nextdxys

main :: IO ()
main = 
    loop
    where
    loop = do
        [h,w] <- readDigits
        unless (h == 0 && w == 0) $ do
            let box = mkBox w h
            let ((sx,sy), (ex,ey)) = bounds box
            putStrLn $ unlines [[box!(x,y) | x<-[sx..ex]] | y<-[sy..ey]]
            loop