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

akhayrutdinov | 30 |

Prateek Gole | 30 |

krushna.sharma | 29 |

StarkMaverick | 28 |

ujjwalgarg | 26 |

Lam Ngoc Pham | 405 |

All Is Well | 399 |

Divvya Sinha | 367 |

Prateek Gole | 347 |

skull tone | 310 |

akhayrutdinov | 3847 |

sanjay05 | 3366 |

Michael Riegger | 2015 |

Jasleen Kaur 2 | 2012 |

Quandray | 1949 |