let rec print_rect x =
  let (h,w) = Scanf.scanf "%d %d\n" (fun x y -> (x,y) )in
  match (h,w) with
    (0,0) -> ()
  | (h,w) ->
     for i=1 to h do
       for j=1 to w do
         if i=1 || i= h then print_string "#"
         else
           if j = 1 || j = w then print_string "#"
           else print_string "."
       done;
       print_newline ();
     done;
     print_newline ();
     print_rect x;;
 let () = print_rect ();;