5. [5 points] On a plane with a given rectangular Cartesian coordinate system, a square is drawn with vertices at points $(0 ; 0),(0 ; 69),(69 ; 69)$, and ( $69 ; 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=69-x$, but neither of the chosen nodes lies on any line parallel to any of the coordinate axes.
Answer: 601460.

Solution. There are two possible cases.

1) Both selected nodes lie on the specified lines. There are 68 points on each of them inside the square, and there are no duplicates among them (the intersection point of the lines has non-integer coordinates). There are 136 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). Since we counted ordered pairs of points, each pair of points was counted twice. Thus, in this case, we get $\frac{136 \cdot 133}{2}=9044$ 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 (136 ways). Now, let's count how many ways there are to choose the second node. There are a total of $68^{2}$ nodes marked in the square; from this, we need to exclude the nodes on the diagonals (136 in total), as well as the nodes that lie on the same horizontal line as the chosen one (66 in total, considering the previously excluded diagonal nodes) or on the same vertical line (66 in total). Therefore, the second node can be chosen in $68^{2}-136-132=$ 4356 ways, and the number of ways to choose a pair of nodes is $136 \cdot 4356=592416$.

Summarizing, we have $9044+592416=601460$ ways.