-- 1_5_B
main =  do  cs <- getLine
            case cs of
                "0 0"   -> return ()
                cs      ->  do  putStrLn $ unlines $ make_a_frame $ map (\x -> read x::Int) $ words cs
                                main
 
make_a_frame :: [Int] -> [String]
make_a_frame [h, w] = [replicate w '#'] ++ replicate (h - 2) ("#" ++ replicate (w - 2) '.' ++ "#") ++ [replicate w '#']