#include using namespace std; vector> spin(vector>& S){ int H=S.size(); int W=S[0].size(); vector> ret(W,vector(H)); for(int i=0;i calc(vector>& S,vector>& query){ int H=S.size(); int W=S[0].size(); int Q=query.size(); vector> one(H,vector(W)); vector> zero(H,vector(W)); vector> w(H,vector(W)); int temp=0; for(int i=0;i ans(Q); vector q; for(int j=0;j> spinquery(vector>& query,int H,int W){ int Q=query.size(); vector> ret(Q,vector(4)); for(int i=0;i>H>>W; vector> S(H,vector(W)); string s; for(int i=0;i>s; for(int j=0;j>Q; vector> query(Q,vector(4)); for(int i=0;i>query[i][j]; query[i][j]--; } } vector k(Q); vector ans(Q); for(int i=0;i<4;i++){ k=calc(S,query); for(int j=0;j