QOJ.ac

QOJ

Süre Sınırı: 2.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Zorluk: [göster] Hack'lenebilir ✓

#14802. What, More Kangaroos?

İstatistikler

There are $n$ kangaroos on a number line, where the $i$-th kangaroo is initially at the positive coordinate $c_i$ (that is, $c_i > 0$), and has two step lengths $a_i$ and $b_i$.

The kangaroos are controlled by pressing the button 1, 2, 3 and 4 on the keyboard. All kangaroos will move simultaneously according to the button pressed. Specifically, let $x_i$ be the current coordinate of the $i$-th kangaroo:

  • Button 1: It will move to $(x_i + a_i)$.
  • Button 2: It will move to $(x_i - a_i)$.
  • Button 3: It will move to $(x_i + b_i)$.
  • Button 4: It will move to $(x_i - b_i)$.

It is allowed for two or more kangaroos to be at the same coordinate. If two kangaroos meet during the movement, they will simply pass through each other.

You can press the buttons as many times as you want. Maximize the number of kangaroos with a negative coordinate (that is, maximize the number of kangaroos with $x_i < 0$) after the operations.

Input

There are multiple test cases. The first line of the input contains an integer $T$ ($1 \le T \le 10^5$) indicating the number of test cases. For each test case:

The first line contains an integer $n$ ($1 \le n \le 2 \times 10^5$) indicating the number of kangaroos.

For the following $n$ lines, the $i$-th line contains three integers $a_i$, $b_i$ and $c_i$ ($-10^9 \le a_i, b_i \le 10^9$, $1 \le c_i \le 10^9$) describing the $i$-th kangaroo.

It is guaranteed that the sum of $n$ of all test cases does not exceed $2 \times 10^5$.

Output

For each test case, output one line containing one integer, indicating the maximum number of kangaroos with a negative coordinate after the operations.

Examples

Input 1

2
4
1 1 1
-1 3 4
0 -2 7
-5 0 10
1
0 0 1

Output 1

3
0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.