printNum::(Int,Bool)->IO()
printNum (n,True) = putStrLn $ take n $ repeat '#'
printNum (1,False) = putStrLn "#"
printNum (n,False) = putStrLn $ "#"++(take (n-2) $ repeat '.')++"#"


printRec::(Int,Int)->IO ()
printRec (a,b) = sequence_ $ (\x->x++[putStrLn ""]) $ map printNum $ map (\x->(b,(x==a||x==1))) $ take a [1,2..]



function::String->IO ()
function x=mapM_ printRec $ takeWhile(/=(0,0))$map (\[x,y]->(read x::Int,read y::Int)) $ map words $ lines x

main = getContents >>= function