#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int H,W,SY,SX; string S[202020]; vector dp[2][9][202020]; int Q,T; map>> Ys[2],Xs[2],YpX[2],YmX[2]; int dy[]={-1,-1,-1,0,0,0,1,1,1}; int dx[]={-1,0,1,-1,0,1,-1,0,1}; void solve() { int i,j,k,l,r,x,y; string s; cin>>H>>W>>SY>>SX; SY--,SX--; FOR(y,H) { cin>>S[y]; FOR(i,2) FOR(j,9) dp[i][j][y].resize(W,1LL<<60); } dp[0][4][SY][SX]=0; deque Q; Q.push_back({4*H*W+SY*W+SX}); while(Q.size()) { int step=Q.front()/(H*W*10); int prev=Q.front()/(H*W)%10; int cy=Q.front()%(H*W)/W; int cx=Q.front()%W; Q.pop_front(); if(prev==4) { FOR(i,9) if(i!=4) { int ty=cy+dy[i]; int tx=cx+dx[i]; if(ty>=0&&ty=0&&tx=0&&ty=0&&tx>x; while(x--) { cin>>SY>>SX>>T; if(dp[T%2][4][SY-1][SX-1]<=T) cout<<"Yes"<