#include using namespace std; typedef long long int ll; typedef double ld; ll gcd(ll a , ll b) { if(b==0) return a; a%=b; return gcd(b,a); } void flipW(vector> & a){ /* cerr<<"flipW\n"; */ for(ll y=0;y> & a){ /* cerr<<"flipH\n"; */ for(ll y=0;y>W>>H>>Sx>>Sy>>Ex>>Ey; vector> a(H/2,vector(W/2)); for(auto &v:a)for(ll &i:v)cin>>i; /* cerr<<"inWH: "< pattern; ll gw = tw/g; ll gh = th/g; ll cw=1; ll ch=1; while(true){ /* cerr << cw << ' ' << ch << " , " << tw << ' ' << th << endl; */ if(cw*th < ch*tw){ // width reaches end first ++cw; pattern.push_back('w'); }else if(cw*th > ch*tw){ // height reaches end first ++ch; pattern.push_back('h'); }else{ // they traverse a corner pattern.push_back('c'); break; } } /* cerr << "G: " << g << endl; */ /* cerr << "Pattern: "; for(char c:pattern) cerr< heights; ll current_height = a[Sy/2][Sx/2]; heights.push_back(current_height); ll sx=Sx,sy=Sy; /* cerr<<"xyz "<