main = 
  let 
    func = do
      line <- getLine
      let 
        [h,w] = map read $ words line :: [Int]
        drawUBLine x 
          | x == w  = do
            putStrLn "#"
          | otherwise = do
            putStr "#"
            drawUBLine (x+1)
        drawLine x 
          | x == 1    = do
            putStr "#"
            drawLine (x+1)
          | x == w    = do
            putStrLn "#"
          | otherwise = do
            putStr "."
            drawLine (x+1)
        drawFrame y
          | y == h    = do
            drawUBLine 1
            putStrLn ""
          | y == 1    = do
            drawUBLine 1
            drawFrame (y+1)
          | otherwise = do
            drawLine 1
            drawFrame (y+1)
        in 
          if h == 0 && w == 0
            then putStr ""
            else do
              drawFrame 1 
              func
    in func

