while 1 do
h,w=gets.split(" ");
h=h.to_i;
w=w.to_i;

if h==0 && w==0 then
        break
end

(1..w).each{|i|
        print "#"
}
print "\n"

(2..h-1).each{|i|
        print "#"
        (2..w-1).each{|j|
                print "."
        }
        print "#\n"
}
(1..w).each{|i|
        print "#"
}
print "\n";
print "\n";
end