Iterating through arrays for mouse clicks using nested while loops

Purpose: to to perform mouse clicks on screen in an array-fashion
ex:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
The macro is to automatically solve a matching game, so I want to click position 1, then click all of the other positions (2-16) and then repeat starting at position 2, etc.

I have 4 array variables who's elements are integers which are the positions of where I want to click. (X and Y)

I am using 4 nested while loops which looks like this:



Comments:
I think the loops aren't truly nested, what is currently happening is X1, Y1, and X2 all stay at their first value while Y2 iterates through its elements until it gets to its last one. But I want to then iterate through X2's elements and repeat Y2's iteration. Then when that's done increment Y1, and re-do the whole Y2 and X2 iterations again, etc.

Any ideas?

Thanks in advance.