So, I have this algorithm for a cipher in Java. I have an alphabet array:

```
char[] alphabet = {'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y'};

```

And also a table that stores characters (based on the input). This isn't that important given that I've checked numerous times and it stores the characters exactly as intended. What I have below is a code so that every letter on a Y axis's letter value in the alphabet array is moved Y+1 times to the right on alphabet's "axis", value which if is over 25 goes back to the first value. Meaning that if 'A' were at Y=0 it would change from the value 1 on the alphabet axis to 2, meaning 'B', and 'X' at Y=2 would have the value of 24 changed to 27, and because it is over 25 it would turn into 27-25=2, 'B'. Why is the code below outputting 'Z' for the letter 'A' located at X=0 Y=0?

```
for(int p = 0; p < number; p++) {
            for(int q = 0; q < number; q++) {
                for(int r = 0; r < 26; r++) {
                    if(table[q][p] == alphabet[r]) {
                        table[q][p] = alphabet[(r+p+1)%26];
                    }
                }
            }
        }

```