#P3619. 魔法

魔法

Description

After cjwssb realized it was a misunderstanding, he apologized to you. To cheer him up, you plan to start doing magic together. However, your time is running out, and worse, you still need to complete nn magic tasks. Suppose your current time is TT. Each task has a constraint tit_i, meaning you can complete this task only when your TT is strictly greater than tit_i. Completing a task does not consume time. When you complete the ii-th task, your time TT increases by bib_i. At all times, TT must remain greater than 00. Determine whether you can complete all nn magic tasks. If yes, output +1s\texttt{+1}\texttt{s}; otherwise, output -1s\texttt{-1}\texttt{s}.

Input Format

The first line contains an integer ZZ, the number of test cases.

For each test case:

  • The first line contains two integers n,Tn, T, meaning there are nn tasks and your initial time is TT.
  • The next nn lines each contain two integers, tit_i and bib_i.

Output Format

For each test case, output +1s\texttt{+1}\texttt{s} or -1s\texttt{-1}\texttt{s}.

1
2 13
1 -9
5 -3

+1s

Hint

  • For 20%20\% of the testdata, n10n \leq 10.
  • For 100%100\% of the testdata, n105n \leq 10^5, Z10Z \leq 10, ti105t_i \leq 10^5, T105T \leq 10^5, 105bi105-10^5 \leq b_i \leq 10^5.

By lantian.

LaTeX\LaTeX By ⚡炭治郎⚡.

Due to historical reasons, the blog discussion may not be able to post the sample output strings. You may consider other ways to work around this.

Translated by ChatGPT 5