#include using namespace std; using ll = long long; int main(){ ll h,w; cin>>h>>w; ll k; cin>>k; vector>> vis(4,vector>(h,vector(w,-1))); int now = 0; vector> ans(h,vector(w,0)); int ni = 0; int nj = 0; int dx = 1; int dy = 1; stack>> st; st.push(make_pair(0,make_pair(0,0))); vis[0][0][0] = 0; bool fn = false; while(true){ if(now==k) break; ans[ni][nj] ^= 1; int nni = ni + dx; if(nni<0||nni>=h){ nni = ni; dx *= -1; } int nnj = nj + dy; if(nnj<0||nnj>=w){ nnj = nj; dy *= -1; } ni = nni; nj = nnj; now++; int mask = 0; if(dx==-1) mask += 1; if(dy==-1) mask += 2; if(vis[mask][nni][nnj]==-1){ vis[mask][nni][nnj] = now; st.push(make_pair(mask,make_pair(nni,nnj))); continue; } if(fn) continue; stack> nxt; ll cnt = 0; pair> want = make_pair(mask,make_pair(nni,nnj)); while(true){ if(st.top()==want){ cnt++; nxt.push(make_pair(nni,nnj)); break; } int nx = st.top().second.first; int ny = st.top().second.second; cnt++; nxt.push(make_pair(nx,ny)); st.pop(); continue; } fn = true; ll res = k - now; ll can = res / cnt; if(can%2==1){ while(nxt.size()){ int ni = nxt.top().first; int nj = nxt.top().second; ans[ni][nj] ^= 1; nxt.pop(); } } now += can * cnt; } for(int i = 0;i