Let \(\alpha\) be the entry \(a_{(i-1)j}\) and let \(\beta\) be the entry \(a_{i(j-1)}\). Then let \(\gamma_\alpha\) be the number of consecutive terms \(a_{(i-1)j}, a_{(i-2)j},...,a_{(i-\gamma_\alpha)j}\) such that they are all equal to \(\alpha\). Define \(\gamma_\beta\) in the natural dual manner. Then set \(a_{ij} = (\gamma_\alpha + \gamma_\beta) \text{ mod } 2\). This defines a matrix of zeroes and ones. Also, set \(a_{00} = 1\) (this is important!)
Or; as a special friend put it, : "Parity of runs top and left XORed"