Donghyeok stands on one cell of a grid with R rows and C columns. Write a program that decides whether he can move so that every cell of the grid is visited exactly K times.
When Donghyeok is on the cell in row r and column c, he can move to (r−1,c) above, (r+1,c) below, (r,c−1) on the left, or (r,c+1) on the right. He cannot move outside the grid.
He may start on any cell and finish on any cell. The cell he starts on counts as one visit.