K-Grid Painter

Control the 50x50 grid below using simplified K-like commands.

The grid state is represented by the variable G (a list of 2500 integers, 0 or 1).

Example commands: