P15766 [JAG 2025 Summer Camp #2] Mix Condiments

Description

You are working in the development department of Incredible Condiment Product Corporation. This company currently sells $n$ kinds of condiments numbered $1$ through $n$. The condiment $i$ has acridity $a_i$ and sourness $s_i$. A recent market research revealed that consumers desire a new condiment of acridity $x$ and sourness $y$, though none of the $n$ condiments has such taste. Here, you wonder whether such a condiment can be manufactured by mixing two of the condiments. If two condiments are mixed to create a new one, its acridity and sourness are the weighted means from the two. More precisely, by mixing $p$ gram of condiment $c$ and $q$ gram of condiment $d$ where $p$ and $q$ are any positive real numbers, the acridity and sourness of the new condiment become $\frac{pa_c + qa_d}{p + q}$ and $\frac{ps_c + qs_d}{p + q}$, respectively. Please find all the possible unordered pairs of condiments such that by mixing those two in some ratio, you can create a condiment of acridity $x$ and sourness $y$.

Input Format

The input consists of a single test case of the following format. $$ \begin{aligned} & n \\ & a_1 \ s_1 \\ & a_2 \ s_2 \\ & \vdots \\ & a_n \ s_n \\ & x \ y \end{aligned} $$ The first line contains an integer $n$ ($2 \leq n \leq 50$) representing the number of condiments that your company currently sells. Each of the following $n$ lines contains two integers $a_i$ and $s_i$ ($0 \leq a_i, s_i \leq 50$) representing the acridity and sourness of condiment $i$. The last line contains two integers $x$ and $y$ ($0 \leq x, y \leq 50$) representing the acridity and sourness of the condiment that consumers desire. It is guaranteed that $(a_i, s_i) \neq (x, y)$ for any $i$ ($1 \leq i \leq n$).

Output Format

Print the answer in the following format. $$ \begin{aligned} & m \\ & c_1 \ d_1 \\ & c_2 \ d_2 \\ & \vdots \\ & c_m \ d_m \end{aligned} $$ $m$ is the number of all pairs of condiments such that by mixing those two in some ratio, you can create a condiment of acridity $x$ and sourness $y$. $c_i$ and $d_i$ ($1 \leq c_i < d_i \leq n$) are the numbers of condiments in each pair. The pairs must be output in the lexicographical order. More precisely, for any $i$ and $j$ ($1 \leq i < j \leq m$), either of the following properties must hold. - $c_i < c_j$ - $c_i = c_j$ and $d_i < d_j$