#include #include using namespace std; int main() { long long H,W,K; cin >> H >> W >> K; vector> m(H,vector(W,0)); int x = 0,y = 0,dx = 1,dy = 1,t = 0; do { m[x][y] = 1-m[x][y]; if(x == 0 && dx == -1)dx = 1; else if(x == H-1 && dx == 1)dx = -1; else x += dx; if(y == 0 && dy == -1)dy = 1; else if(y == W-1 && dy == 1)dy = -1; else y += dy; t++; } while(x != 0 || y != 0 || m[0][0]); K %= t; while(K--) { m[x][y] = 1-m[x][y]; if(x == 0 && dx == -1)dx = 1; else if(x == H-1 && dx == 1)dx = -1; else x += dx; if(y == 0 && dy == -1)dy = 1; else if(y == W-1 && dy == 1)dy = -1; else y += dy; } for(int i=0;i