let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

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

let rec repl () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] | [_] -> exit 1
  | h :: w :: _ ->
      if (h = 0) && (w = 0) then ()
      else begin
        print_rectangle h w;
        print_newline ();
        repl ()
      end

let () =
  try repl () with End_of_file -> ()