Let $M:=\begin{pmatrix}1 & 2 & 7 & 4 \\ 0 & 3 & -2 & 1 \\ 3 & 0 & 3 & 0 \\ 4 & 1 & 3 & 1 \end{pmatrix}\in M(4\times4,\mathbb{Z}/p\mathbb{Z})$, where $p$ is a prime number.
Assignment: Find the rank and the determinant of $M$.
My problem is that since $p$ is an arbitrary prime number, one has to do the calculation of the rank via row reduction in the following way:$$M=\begin{pmatrix}1\mod p & 2\mod p & 7\mod p & 4\mod p \\ 0 & 3\mod p & p-(2\mod p) & 1\mod p \\ 3\mod p & 0 & 3\mod p & 0 \\ 4\mod p & 1\mod p & 3\mod p & 1\mod p \end{pmatrix}$$
and trying to make $m_{3,1}=0$, in the next step we get
$$\begin{pmatrix}1\mod p & 2\mod p & 7\mod p & 4\mod p \\ 0 & 3\mod p & p-(2\mod p) & 1\mod p \\ 0 & 0+((p-3)\mod p)\cdot 2\mod p)\mod p & ... & ... \\ ... & ... & ... & ... \end{pmatrix}$$ and we can see that as one continues to row reduce the matrix, it continues to become more and more complicated-looking, with similar problems arising in the computation of the determinant.
I suggest you start with the determinant, not the rank. If you calculate the determinant of $M$, using any method of your choice, you'll get that this determinant is $-54$, or rather $$\det M=-54=-2\cdot3^3 \pmod{p}.$$ This shows that $M$ is invertible for any $p\neq2,3$. For these two remaining primes, you can work it out explicitly.