5. [5 points] On a plane with a given rectangular Cartesian coordinate system, a square is drawn with vertices at points $(0 ; 0),(0 ; 63),(63 ; 63)$, and $(63 ; 0)$. Find the number of ways to choose two grid nodes inside this square (not including its boundary) such that at least one of these nodes lies on one of the lines $y=x$ or $y=63-x$, but neither of the chosen nodes lies on any line parallel to any of the coordinate axes.
Answer: 453902.

Solution. There are two possible cases.

1) Both selected nodes lie on the specified lines. There are 62 points on each of them inside the square, and there are no repetitions among them (the intersection point of the lines has non-integer coordinates). There are 124 ways to choose the first point, and 3 fewer ways to choose the second (all points are suitable except the first and the two points lying on the same horizontal or vertical line as the first). In this case, we counted each pair of points twice since we considered ordered pairs of points. Therefore, in this case, we get $\frac{124 \cdot 121}{2}=7502$ ways.
2) Exactly one of the selected nodes lies on the lines given in the condition. First, choose the node lying on one of the lines (124 ways). Now, let's count how many ways there are to choose the second node. In total, there are $62^{2}$ nodes marked in the square; from this, we need to exclude the nodes on the diagonals (124 nodes), as well as the nodes that lie on the same horizontal (60 nodes, considering the previously excluded diagonal nodes) or vertical (60 nodes) line as the chosen one. Therefore, the second node can be chosen in $62^{2}-124-120=3600$ ways, and the number of ways to choose a pair of nodes is $124 \cdot 3600=446400$.

Summarizing, we have $7502+446400=453902$ ways.