outerFrameLine w = replicate w '#'
innerFrameLine w = "#" ++ (replicate (w-2) '.') ++ "#"
drawFrame h w totH
    | h == totH = putStrLn (outerFrameLine w) >> drawFrame (h-1) w totH
drawFrame 1 w _ = putStrLn (outerFrameLine w) >> putStrLn ""
drawFrame h w totH = putStrLn (innerFrameLine w) >> drawFrame (h-1) w totH

main = do
    ln <- getLine
    let [h,w] = map read $ words ln :: [Int]
    if h == 0 && w == 0 then
        return ()
    else do
        drawFrame h w h
        main