solveImpl :: [Int] -> [String]
solveImpl [h,w] = take h $ repeat $ take w $ repeat '.'

solve :: [Int] -> [String]
solve [h,w] = (l ++) $ (++ l) $ map ("#"++) $ map (++"#") $ solveImpl [h-2 , w-2]
    where
        l = [take w $ repeat '#']

main :: IO ()
main  = getContents
    >>= return . map (map read) . map words . lines
    >>= return . takeWhile (/= [0,0])
    >>= return . map solve
    >>= mapM_ (\ x -> mapM_ putStrLn x >> putStrLn "")