let print_frame h w = (for i = 1 to h do
                         for j = 1 to w do
                           print_char (if 1 < i && i < h && 1 < j && j < w then '.'
                                       else '#')
                         done;
                         print_newline()
                       done) ;;

let rec f() = Scanf.scanf "%d %d\n" (fun h w -> if h > 0 && w > 0 then
                                                  begin
                                                    print_frame h w;
                                                    print_newline();
                                                    f()
                                                  end) ;;
f() ;;
