main = do
    ss <- getLine
    let hw = map (\x -> read x :: Int) $ words ss
    let h = hw!!0
    let w = hw!!1
    if (h==0 && w==0)
        then return ()
        else do
            draw h w
            main

draw h w = do
    drawFrame 1 h w
    
drawFrame i h w = do
    let line = if (i==1) || (i==h)
                   then replicate w '#'
                   else "#" ++ replicate (w-2) '.' ++ "#"
    putStrLn line
    if i==h
        then putStrLn ""
        else drawFrame (i+1) h w
