CF1923B.Monsters Attack!

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Monsters Attack!

You are playing a computer game. The current level of this game can be modeled as a straight line. Your character is in point 00 of this line. There are nn monsters trying to kill your character; the ii-th monster has health equal to aia_i and is initially in the point xix_i.

Every second, the following happens:

  • first, you fire up to kk bullets at monsters. Each bullet targets exactly one monster and decreases its health by 11. For each bullet, you choose its target arbitrary (for example, you can fire all bullets at one monster, fire all bullets at different monsters, or choose any other combination). Any monster can be targeted by a bullet, regardless of its position and any other factors;
  • then, all alive monsters with health 00 or less die;
  • then, all alive monsters move 11 point closer to you (monsters to the left of you increase their coordinates by 11, monsters to the right of you decrease their coordinates by 11). If any monster reaches your character (moves to the point 00), you lose.

Can you survive and kill all nn monsters without letting any of them reach your character?

Input

The first line of the input contains one integer tt (1t31041 \le t \le 3 \cdot 10^4) — the number of test cases.

Each test case consists of three lines:

  • the first line contains two integers nn and kk (1n31051 \le n \le 3 \cdot 10^5; 1k21091 \le k \le 2 \cdot 10^9);
  • the second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9);
  • the third line contains nn integers x1,x2,,xnx_1, x_2, \dots, x_n ($-n \le x_1 \lt x_2 \lt x_3 \lt \dots \lt x_n \le n$; xi0x_i \ne 0).

Additional constraint on the input: the sum of nn over all test cases does not exceed 31053 \cdot 10^5.

Output

For each test case, print YES if you can kill all nn monsters before they reach your character, or NO otherwise.

You can output each letter of the answer in any case (upper or lower). For example, the strings yEs, yes, Yes, and YES will all be recognized as positive responses.

Note

In the first example, you can act as follows:

  • during the 11-st second, fire 11 bullet at the 11-st monster and 11 bullet at the 33-rd monster. Then the 11-st monster dies, the 22-nd and the 33-rd monster move closer;
  • during the 22-nd second, fire 22 bullets at the 22-nd monster. Then the 22-nd monster dies, the 33-rd monster moves closer;
  • during the 33-rd second, fire 22 bullets at the 33-rd monster. Then the 33-rd monster dies.

In the second example, you can fire only 11 bullet, so you can kill only one of the two monsters during the 11-st second. Then, the remaining monster moves closer and kills your character.

Samples

5
3 2
1 2 3
-1 2 3
2 1
1 1
-1 1
4 10
3 4 2 5
-3 -2 1 3
5 3
2 1 3 2 5
-3 -2 3 4 5
2 1
1 2
1 2
YES
NO
YES
YES
NO

在线编程 IDE

建议全屏模式获得最佳体验