Under construction

Still being built. Things may change

123456789 Points

Interview

Time limit0.2sMemory limit512 MB

Summary
Given N notes and a target score S, find counts of Perfect, Great, Good judgments giving exactly S, or report -1.
Level

Medium6 of 10

Topics
Math, Binary search, Implementation, Number theory
Solved
No attempts yet

Problem

Itchangmyeong plays a rhythm game as a hobby. Hitting notes that fall from the top with accurate timing earns a high score.

Each note that is hit receives one of the following judgments.

  • Perfect
  • Great
  • Good
  • Miss

A note that is not hit receives a Miss judgment. There are no judgments other than these four. In a song with N notes, the score when a Perfect, b Great, and c Good judgments are received is computed by the following formula. The fractional part is discarded.

⌊109×2a+2b+c2N+a⌋\biggl\lfloor {10^9 \times \frac{2a + 2b + c}{2N} + a} \biggr\rfloor

In other words, taking the Good judgment score 1092N\frac{10^9}{2N} as the base, the score of each judgment is as follows.

  • Perfect = 2 Good + 1
  • Great = 2 Good
  • Good = 1 Good
  • Miss = 0

For example, in a song with 100 notes, receiving 10 Perfect, 20 Great, and 30 Good judgments earns 450,000,010 points. The maximum score in this case is 109+N points, obtained by receiving Perfect judgments on all N notes.

Itchangmyeong wants to earn exactly 123,456,789 points in this game and surprise people. Itchangmyeong is a top-tier player, so he can set the judgment of every note as he likes. Given the number of notes in the song he is going to play, write a program that computes how he should play the song to earn the score he wants.

Input

The first line gives the number of test cases T (1 ≤ T ≤ 2,000). The next lines give T test cases.

In each test case, one line gives the number of notes N (1 ≤ N ≤ 20,000) and the score S (0 ≤ S ≤ 109+N) that Itchangmyeong wants, separated by a space. N and S are integers.

Output

For each test case, output the following on one line.

  • If Itchangmyeong can earn exactly S points by receiving a Perfect, b Great, and c Good judgments, output 2a+2b+c and a separated by a space. No input has more than one possible pair (2a+2b+c, a).
  • If Itchangmyeong cannot earn exactly S points no matter how he plays the song, output -1.

Examples1

  1. Example 1

    Input
    3
    1000 1000001000
    4318 899954000
    20000 123456789
    
    Expected output
    2000 1000
    7772 318
    -1