#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include #include using namespace std; using ll=long long; using ld=long double; using st=string; using P=pair; typedef atcoder::modint mint; ll inf=9e18; template constexpr auto max(T... a){return max(initializer_list>{a...});} template constexpr auto min(T... a){return min(initializer_list>{a...});} template auto vec(const ll (&sizes)[s], const T& init = T()){ if constexpr(i < s) return vector(sizes[i], vec(sizes, init)); else return init; } ll h,w,a,b,r1,r2,c1,c2,p,q; struct xys{ll x,y,s;}; ll bfs_grid(vector &map,vector>> &step,xys s,ll state,ll d=4){ vector dx,dy; step=vec({h,w,state},-1); if(d==4){dx={1,0,-1,0};dy={0,1,0,-1};} if(d==8){dx={1,1,0,-1,-1,-1,0,1};dy={0,1,1,1,0,-1,-1,-1};} if(s.s==0&&r1<=s.x&&s.x<=r2&&c1<=s.y&&s.y<=c2) s.s=1; if(s.s==1&&s.x==p&&s.y==q) s.s=2; if(s.s==2&&s.x==a&&s.y==b) return 0; // Goal step[s.x][s.y][s.s]=0; queue Q; Q.push(s); while(!Q.empty()){ auto pre=Q.front(); Q.pop(); for(ll i=0;i"<>h>>w>>a>>b>>r1>>c1>>r2>>c2>>p>>q; --a,--b,--r1,--c1,--r2,--c2,--p,--q; auto v=vec({h},""); auto step=vec({h,w,3},0); cout<