In general for this type problem:
To find: the value of $z$ without first finding $x,y$.
Calculate the determinant of the matrix with rows
$[a, b, c]$
$[d, e, f]$
$[g, h, z].$
Multiply it out and get the factor in front of z (this better be nonzero mod n), and move the numerical terms of the determinant to the other side. Now divide by what's in front of $z$ to get $z$ mod $n$.
For the above example the rows are [2,5,1],[5,1,2],[5,7,z] and the determinant is $-23z+52.$ So z = 52/23 = 0 since 13 divides 52 and 23 isn't zero mod 13. In general this method involves finding the inverse mod $n$ of the coefficient of $z$
The reason the method works is that the three equations are equivalent to saying that the three rows of the matrix are all orthogonal to the vector $[x,y,-1]$. Therefore they lie in a two dimensional subspace of $R^3$ and are linearly dependent, making the determinant $0$.