#include #include #define eb emplace_back #define all(a) (a).begin(),(a).end() #define done(...) return pp(__VA_ARGS__) #define RD(T,...) T __VA_ARGS__;li(__VA_ARGS__) #define LL(...) RD(ll,__VA_ARGS__) #define VE(a,...) auto a=vec(__VA_ARGS__) #define JO(a,b) a##b #define jo(a,b) JO(a,b) #define uqsymb(a) jo(a,__LINE__) #define FE(v,e,...) for(auto&&__VA_OPT__([)e __VA_OPT__(,__VA_ARGS__]):v) #define FO(n) for(ll uqsymb(i)=n;uqsymb(i)-->0;) #define FOR(i,...) for(auto[i,i##O,i##E]=rng(0,__VA_ARGS__);i=i##O;i-=i##E) using std::cin,std::cout,std::begin,std::end,std::rbegin; using std::swap,std::move,std::abs,std::prev,std::next; using std::tuple,std::bitset,std::minmax,std::get; using vo=void;using bo=bool; vo solve(); using is=std::istream;using os=std::ostream; using dd=long double;using ll=long long;using ull=unsigned long long; using lll=__int128_t;using ulll=__uint128_t;using str=std::string; using namespace atcoder;using ml=modint;auto&operator<<(os&o,const ml&x){return o<bo at2(T x,ll i){return x>>i&1;} templatebo in(T l,U m,V r){return l<=m&&mT zz(T x){return x<0?-x:x;} templatell len(const T&a){return a.size();} struct edg{ ll t,w; edg(){} edg(ll t,ll w=1):t(t),w(w){} friend os&operator<<(os&o,const edg&e){return o<struct cp{ A a={};B b={}; cp(){} cp(A a,B b):a(a),b(b){} cp(std::pairp):a(p.first),b(p.second){} bo operator==(const cp&c)const{return a==c.a&&b==c.b;} bo operator<(const cp&c)const{return a!=c.a?a(const cp&c)const{return a!=c.a?a>c.a:b>c.b;} friend is&operator>>(is&i,cp&c){return i>>c.a>>c.b;} friend os&operator<<(os&o,const cp&c){return o<; templatestruct tr{ A a={};B b={};C c={}; tr(){} tr(A a,B b,C c):a(a),b(b),c(c){} bo operator==(const tr&t)const{return a==t.a&&b==t.b&&c==t.c;} auto operator<(const tr&t)const{return a!=t.a?a>(is&i,tr&t){return i>>t.a>>t.b>>t.c;} friend os&operator<<(os&o,const tr&t){return o<; templateT&rv(T&a){reverse(all(a));return a;} templatedecltype(auto)rb(T&a){return*rbegin(a);} templateauto pot(T&a){auto r=a.top();a.pop();return r;} templatestruct deq:std::deque{ using std::deque::deque; deq(const std::vector&a={}){fe(a,e)this->eb(e);} friend os&operator<<(os&o,const deq&q){fe(q,e)o<struct ve; templateconstexpr bo isv=0; templateconstexpr bo isv> =1; templateconstexpr bo isv> =1; templateauto rawv(V){if constexpr(isv)return rawv(V(1)[0]);else return V();} templatestruct ve:std::vector{ using std::vector::vector; using T=decltype(rawv(V())); templateve(const std::vector&v={}){fe(v,e)this->eb(e);} auto&operator+=(const ve&u){auto&v=*this;fo(i,len(v))v[i]+=u[i];return v;} auto&operator-=(const ve&u){auto&v=*this;fo(i,len(v))v[i]-=u[i];return v;} auto&operator^=(const ve&u){fe(u,e)this->eb(e);return*this;} auto&operator+=(const T&x){auto&v=*this;fe(v,e)e+=x;return v;} auto&operator-=(const T&x){auto&v=*this;fe(v,e)e-=x;return v;} auto&operator*=(const T&x){auto&v=*this;fe(v,e)e*=x;return v;} templateauto&operator+=(const bitset&a){fo(i,n)(*this)[i]+=a[i];return*this;} templateauto&operator-=(const bitset&a){fo(i,n)(*this)[i]-=a[i];return*this;} auto operator+(const ve&u){return ve(*this)+=u;} auto operator-(const ve&u){return ve(*this)-=u;} auto operator^(const ve&u){return ve(*this)^=u;} auto operator+(const T&x){return ve(*this)+=x;}auto&operator++(){return*this+=1;} auto operator-(const T&x){return ve(*this)-=x;}auto&operator--(){return*this-=1;} auto operator*(const T&x){return ve(*this)*=x;}auto operator-(){return ve(*this)*=-1;} auto lower_bound(const V&x)const{return std::lower_bound(all(*this),x);} auto upper_bound(const V&x)const{return std::upper_bound(all(*this),x);} auto de(const str&b="a"){std::conditional_t,ve,str>r;fe(*this,e)if constexpr(isv)r.eb(e.de(b));else r+=len(b)==1?e+b[0]:b[e];return r;} }; templateauto vec(const ll(&s)[n],T x={}){if constexpr(n==i+1)return ve(s[i],x);else{auto X=vec(s,x);return ve(s[i],X);}} templatevo setsize(const ll(&l)[n],A&...a){((a=vec(l,rawv(a))),...);} templateusing vve=ve>;using vl=ve;using vvl=vve; using gl=ve>;using ge=ve>; struct io{io(){cin.tie(0)->sync_with_stdio(0); cout<os&operator<<(os&o,const bitset&b){fo(i,n)o<os&operator<<(os&o,const tuple&t){ apply([&](const auto&...a){ll i=0;(((o<os&operator<<(os&o,const std::vector&v){fe(v,e)o<?nl:sp);return o;} templatevo pp(const A&...a){ll i=0;((cout<is&operator>>(is&i,std::vector&v){fe(v,e)i>>e;return i;} templatevo li(A&...a){(cin>>...>>a);} vl sien(const str&b="a"){str s;li(s);vl r;fe(s,e)r.eb(len(b)==1?e-b[0]:b.find_first_of(e));return r;} vvl sien(ll n,const str&b="a"){vvl r;fo(n)r.eb(sien(b));return r;} templatestruct rec:F{rec(F&&f):F(std::forward(f)){}templatedecltype(auto)operator()(A&&...a)const{return F::operator()(*this,std::forward(a)...);}}; int main(){ll T=1;fo(T)solve();} vo solve(){ LL(H,W,K,L,R); vvl s=sien(H,".#"); if(odd(H+W-2+K))done(no()); if(odd(K))done(no()); VE(safe,{H,W},short()); fo(i,H)fo(j,W)if(!s[i][j]){ ll t=0; fo(k,4){ ll ni=i+dx[k],nj=j+dy[k]; if(!in(0,ni,H)||!in(0,nj,W))continue; if(s[ni][nj])continue; t|=pw2(k); } if(at2(t,0)&&at2(t,2))safe[i][j]=1; if(at2(t,1)&&at2(t,3))safe[i][j]=2; } VE(dist1,{H,W},short(-1)); VE(dist2,{H,W},short(-1)); auto bfs_on_grid=[&](auto&dist,short sx=0,short sy=0){ dist[sx][sy]=0; deqq{{sx,sy}}; while(len(q)){ auto[x,y]=q.front();q.pop_front(); fo(k,4){ ll nx=x+dx[k],ny=y+dy[k]; if(!in(0,nx,H)||!in(0,ny,W))continue; if(s[nx][ny])continue; if(dist[nx][ny]==-1)dist[nx][ny]=dist[x][y]+1,q.eb(nx,ny); } } }; bfs_on_grid(dist1,0,0); bfs_on_grid(dist2,H-1,W-1); if(dist1[H-1][W-1]==-1)done(no()); fo(i,H)fo(j,W)if(safe[i][j]){ if(dist1[i][j]==-1||dist2[i][j]==-1)continue; if(dist1[i][j]