Example
For p = 11 and x = 2 this gives the following pattern.
It consists of the squares with matrix-coordinates (1,1), (2,2), (3,4), (4,8), (5,5), (6,10), (7,9), (8,7), (9,3), (10,6).