High School Programming League 2008/2009

Poppy seed

Problem code: HS09POP

A kingdom far, far away is ruled by a king who has a beautiful daughter. Many knights would like to marry her, but the wise father has to test their abilities first. His court shaman has invented a puzzle, which he puts before each candidate for the princess' hand in marriage. Here it is:

  • There are N bins arranged in a circle,
  • Every bin is filled with some number of poppy seeds,
  • The shaman divided the poppy seeds from the first bin into N equal parts, threw one part into bin number two, and the rest back into the first bin.
  • He then divided the poppy seeds from the second bin into N equal parts, threw one part into bin number three, and the rest back into the second bin.
  • He repeated the procedure for every other bin.
  • Eventually he divided the poppy seeds from the N-th bin into N equal parts, and threw one part into bin number one and the rest back into the N-th bin.
  • After all this it turned out there were exactly A seeds in every bin.

The shaman now asks the knight if this is possible?

One knight is deeply in love with the princess and hence asks you for help with the riddle.

Input

Standard input contains K (1 ≤ K ≤ 10 000) lines, each containing two values N, A (4 ≤ N ≤ 30 000, 200 ≤ A ≤ 10200) separated by spaces. In line K+1 there are two zeros separated by spaces. Do not process this test case.

Output

Write K lines of output. In each line, print the word 'Yes', if the situation described by the shaman possible for the data in the corresponding line of input or the word 'No' in the opposite case.

Example

Input:
5 32
4 17
0 0
Output:
Yes
No

Scoring

By solving this problem you will score 10 points.


Added by:Adam Dzedzej
Date:2009-12-09
Time limit:1s
Source limit:50000B
Languages:SED C99 strict C++ 4.0.0-8 C++ 4.3.2 TCL SCALA NICE NEM BASH PHP SCM guile LISP sbcl LISP clisp ERL TECS TEXT DOC PDF PS PERL 6 JS
Resource:High School Programming League (thanks to Talent Association)
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.