import Data.Functor( (<$>))

main = do
    ls <- (takeWhile ("0 0"/=)) . lines <$> getContents
    let
	hws = (read <$>) . words <$> ls
	printRect [h,w] = putStrLn `mapM_` rect >> putStrLn ""
	  where
	    top = take w $ repeat '#'
	    bottom = top
	    mid = '#':(take (w-2) $ repeat '.')++"#"
	    rect = top:
		    (take (h-2) $ repeat mid)
		    ++[bottom]

    printRect `mapM_` hws

