In the movie ”Prison break $4$”. Michael Scofield has to break into The Company. There, he encountered a kind of code to protect Scylla from being taken away.  This code require picking out every number in a $2015\times 2015$ grid satisfying:
i) The number right above of this number is $\equiv 1 \mod 2$
ii) The number right on the right of this number is    $\equiv 2 \mod 3$
iii) The number right below of this number is    $\equiv 3 \mod 4$
iv) The number right on the right of this number is    $\equiv 4 \mod 5$ .
How many number does Schofield have to choose?
Also,  in a $n\times n$  grid,  the numbers from $ 1$ to $n^2$ are arranged in the following way :
On the first row, the numbers  are written in an ascending order $1, 2, 3, 4, ..., n$, each cell has one number.  
On the second row, the number are written in descending order $2n, 2n -1, 2n- 2, ..., n + 1$.   
On the third row,   it is ascending order again $2n + 1, 2n + 2, ..., 3n$.  
The numbers are written like that until $n$th row.  
For  example, this is how a $3$ $\times$ $3$ board looks like:[img]https://cdn.artofproblemsolving.com/attachments/8/7/0a5c8aba6543fd94fd24ae4b9a30ef8a32d3bd.png[/img]
To solve this problem, we need to identify the numbers in a \(2015 \times 2015\) grid that satisfy the given modular conditions. Let's break down the problem step by step.

1. **Understanding the Grid Layout:**
   - The grid is filled with numbers from \(1\) to \(2015^2\).
   - The first row is filled with numbers in ascending order: \(1, 2, 3, \ldots, 2015\).
   - The second row is filled with numbers in descending order: \(2 \times 2015, 2 \times 2015 - 1, \ldots, 2015 + 1\).
   - This pattern continues, alternating between ascending and descending order for each row.

2. **Conditions to Satisfy:**
   - The number right above the current number is \(\equiv 1 \mod 2\).
   - The number right on the right of the current number is \(\equiv 2 \mod 3\).
   - The number right below the current number is \(\equiv 3 \mod 4\).
   - The number right on the right of the current number is \(\equiv 4 \mod 5\).

3. **Analyzing the Conditions:**
   - Let the current number be \(a_{i,j}\) where \(i\) is the row index and \(j\) is the column index.
   - The number right above \(a_{i,j}\) is \(a_{i-1,j}\).
   - The number right on the right of \(a_{i,j}\) is \(a_{i,j+1}\).
   - The number right below \(a_{i,j}\) is \(a_{i+1,j}\).
   - The number right on the right of \(a_{i,j}\) is \(a_{i,j+1}\).

4. **Modular Conditions:**
   - \(a_{i-1,j} \equiv 1 \mod 2\)
   - \(a_{i,j+1} \equiv 2 \mod 3\)
   - \(a_{i+1,j} \equiv 3 \mod 4\)
   - \(a_{i,j+1} \equiv 4 \mod 5\)

5. **Finding the Numbers:**
   - We need to find \(a_{i,j}\) such that the above conditions are satisfied.
   - Since \(a_{i,j+1}\) must satisfy both \(\equiv 2 \mod 3\) and \(\equiv 4 \mod 5\), we use the Chinese Remainder Theorem (CRT) to find a common solution.
   - Solve the system:
     \[
     \begin{cases}
     x \equiv 2 \mod 3 \\
     x \equiv 4 \mod 5
     \end{cases}
     \]
   - Using CRT, we find \(x \equiv 14 \mod 15\).

6. **Checking the Grid:**
   - We need to check if \(a_{i,j}\) can be such that \(a_{i-1,j} \equiv 1 \mod 2\) and \(a_{i+1,j} \equiv 3 \mod 4\).
   - Since the grid alternates between ascending and descending order, we need to check the positions of \(14, 29, 44, \ldots\) in the grid.

7. **Counting the Numbers:**
   - We need to count how many such numbers exist in the \(2015 \times 2015\) grid.
   - The numbers \(14, 29, 44, \ldots\) form an arithmetic sequence with a common difference of \(15\).
   - The total number of terms in this sequence within the range \(1\) to \(2015^2\) is given by:
     \[
     n = \left\lfloor \frac{2015^2 - 14}{15} \right\rfloor + 1
     \]
   - Calculate:
     \[
     n = \left\lfloor \frac{2015^2 - 14}{15} \right\rfloor + 1 = \left\lfloor \frac{4060225 - 14}{15} \right\rfloor + 1 = \left\lfloor \frac{4060211}{15} \right\rfloor + 1 = 270680 + 1 = 270681
     \]

The final answer is \(\boxed{270681}\).