{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"There are $n$ red balls kept on the positive $X$ axis, and $m$ blue balls kept on the positive $Y$ axis. You are given the positions of the balls. For each $i$ from $1$ to $n$, the $i$-th red ball has the coordinates $(x_i, 0)$, where $x_i$ is a positive integer. For each $i$ from $1$ to $m$, the $i$-th blue ball has the coordinates $(0, y_i)$, where $ y_i$ is a positive integer. \r\n\r\nIt is given that all $x_i$ are distinct. Also, all $y_i$ are distinct.\r\n\r\nAt the time $t\u003d 0$, for each $i$ from $1$ to $n$, the $i^{\\text{th}}$ red ball is thrown towards positive $Y$ axis with a speed of $u_i$( that is, with velocity vector $(0, u_i)$). Simultaneously (at time $t \u003d 0$), for each $i$ from $1$ to $m$, the $i^{\\text{th}}$ blue ball is thrown towards positive $X$ axis with a speed of $v_i$ (that is, with velocity vector $(v_i, 0)$).\r\n\r\nTwo balls are said to collide if they are at the same position at the same time. When two balls collide, they disappear, and hence no longer collide with other balls. (See sample examples for clarification).\r\n\r\nFind the total number of collisions the balls will have.\r\n\r\n### Input\r\n- First line contains $n$ and $m$, the number of red balls, and the number of blue balls, respectively. \r\n- $i^{\\text{th}}$ of the next $n$ lines contains two space separated integers $x_i$ and $u_i$, the position and speed of the $i^{\\text{th}}$ red ball respectively\r\n- $i^{\\text{th}}$ of the next $m$ lines contains two space separated integers $y_i$ and $v_i$, the position and speed of the $i^{\\text{th}}$ blue ball respectively\r\n\r\n### Output\r\nPrint the number of collisions.\r\n\r\n### Constraints \r\n- $1 \\le n, m \\le 10^5$\r\n- $1 \\le x_i, u_i, y_i, v_i \\le 10^9$\r\n- for all $1 \\le i \\lt j \\le n, x_i \\neq x_j$\r\n- for all $1 \\le i \\lt j \\le m, y_i \\neq y_j$\r\n\r\n### Example Input 1\r\n```\r\n1 1\r\n1 2\r\n2 1\r\n```\r\n\r\n### Example Output 1\r\n```\r\n1\r\n```\r\n\r\n### Example Input 2\r\n```\r\n1 2\r\n1 2\r\n2 1\r\n1 2\r\n```\r\n\r\n### Example Output 2\r\n```\r\n1\r\n```\r\n\r\n### Explanation\r\n**Example case 1:** The balls collide at t \u003d 1, at the coordinates (1, 2). \r\n\r\n**Example case 2:** The red ball and the second blue ball collide at time 0.5 at coordinates (1, 1). Note that the first blue ball would have collided with the red ball at t \u003d 1 (like in sample input # 1), if the second blue ball wasn\u0027t present. But since the red ball disappears at t \u003d 0.5, its collision with first blue ball doesn\u0027t happen. The total number of collisions is 1.\r\n"}}]}