let () =
  let rec loop () = 
    let h, w = Scanf.scanf "%d %d\n" (fun h w -> h, w) in
    if h = 0 && w = 0 then ()
    else
      (print_endline (String.make w '#');
      for _ = 2 to h-1 do
        let s = String.make w '.' in
        (s.[0] <- '#'; s.[w-1] <- '#';
        print_endline s;)
      done;
      print_endline (String.make w '#');
      print_endline "";
      loop ())
  in loop ()