BETA

#### Submissions: 68 Accuracy: 19.12%

Balancing Pan

Given a simple weighting scale with two pans, we are given a weight T and some other weights which are the powers of a specific number a, our goal is to balance these pans using the given weights. More formally we need to satisfy this equation,
T + (some power of a) = (some other powers of a)
Remember that we are given exactly one weight corresponding to one power.

```Examples:
Input  : T = 11    and  a = 4
Then scale can be balanced as,
11 + 4 + 1 = 16
Output  : YES, pans can be balanced```

Input :
The first line of input contains an integer Test denoting the Test cases. Then Test test cases follow.
Second line contains value of T and a.

Output :
Yes, if pans can be balanced; else NO

Constraints :
1 ≤ Test ≤ 50
1 ≤ a ≤ T ≤ 1000

Input :
1
4 11

Output :
YES

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Mohit Gupta_OMG :)

##### It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result: