main :: IO ()
main = do ls <- getContents
          putStr (compose ls)

compose :: String -> String
compose = unlines . fmap unlines . rects . fmap (toTupleofInts . take 2 . words) . lines
          where
            toTupleofInts =  (\[x,y] -> (x,y)) . fmap (\x -> read x::Int)

rects :: [(Int, Int)] -> [[String]]
rects [] = []
rects ((m, n):xs) | m == 0 && n == 0 = []
                  | otherwise = rect m n m : rects xs

rect :: Int -> Int -> Int -> [String]
rect 0 _ _ = []
rect m n l | m == 1 || m == l = replicate n '#' : rect (m - 1) n l
           | otherwise = ("#" ++ replicate (n - 2) '.' ++ "#") : rect (m - 1) n l