Xor Sum

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Determine whether there exists a sequence of NN nonnegative integers a_1,a_2,,a_Na\_1,a\_2,\cdots,a\_N that satisfies all of the following conditions, and if it exists, find the minimum possible value of the maximum of the array.

  • a_1+a_2++a_N=Sa\_1+a\_2+\cdots+a\_N=S
  • a_1a_2a_N=Xa\_1 \oplus a\_2 \oplus \cdots \oplus a\_N=X (Here \oplus denotes bitwise xor operation)

Note that there are TT tests in one input file.

입력

Input is given from Standard Input in the following format:

TT

N_1N\_1 S_1S\_1 X_1X\_1

N_2N\_2 S_2S\_2 X_2X\_2

\vdots

N_TN\_T S_TS\_T X_TX\_T

Here, N_i,S_i,X_iN\_i,S\_i,X\_i represent values of N,S,XN,S,X for the ii-th test, respectively.

출력

Print TT lines. In the ii-th line, print 1-1 if there doesn't exist an array with the mentioned property in the ii-th test, and print the minimum possible value of the maximum of the array if it exists.

제한

  • 1T5001 \leq T \leq 500
  • 1N26011 \leq N \leq 2^{60}-1
  • 0S26010 \leq S \leq 2^{60}-1
  • 0X26010 \leq X \leq 2^{60}-1
  • All values in input are integers.

힌트

The following is a solution for each test:

  • (3,3,3)
  • (2,2,2,2)
  • (2,3,3,3,4,4)
  • (15)
  • Impossible
  • Impossible