You are looking for pairs which satisfy the given conditions. These pairs are represented by points which belong to the quadrilateral painted in grey (see attachment)
The maximum of P will be obtained if the line
passes at least through one point of the quadrilateral such that the is as great as possible. This happens if the line passes through the point Q(1, 4). Then P = 6.