Chef has bought N robots to transport cakes for a large community wedding. He has assigned unique indices, from 1 to N, to each of them. How it will happen?
Chef arranges the N robots in a row, in the (increasing) order of their indices. Then, he chooses the first M robots and moves them to the end of the queue. Now, Chef goes to the robot at the first position in the row and hands it one cake. He then notes this robot's index (say k) in his notebook, and goes to the kth position in the row. If the robot at this position does not have a cake, he give him one cake, notes his index in his notebook, and continues the same process. If a robot visited by Chef already has a cake with it, then he stops moving and the cake assignment process is stopped.
Chef will be satisfied if all robots have a cake in the end. In order to prepare the kitchen staff for Chef's wrath (or happiness :) ), you must find out if he will be satisfied or not? If not, you have to find out how much robots have a cake, so that the kitchen staff can prepare themselves accordingly.

-----Input-----
- The first line of input contains a single integer T denoting the number of test cases.
- The single line of each test cases contains two space separated integers N and M.

-----Output-----
For each of the T test cases, output a single line:

- If all N robots have a cake, output "Yes" (without quotes).
- Otherwise, output "No" (without quotes) followed by a space and the number of robots which have a cake.

-----Constraints and Subtasks-----
- 1 ≤ T ≤ 10
- 0 ≤ M < NSubtask 1: 25 points
- 1 ≤ N ≤ 10^5Subtask 3: 75 points
- 1 ≤ N ≤ 10^9

-----Example-----
Input:
3
2 0
2 1
4 2

Output:
No 1
Yes
No 2

-----Explanation-----
In test case 1, we have two robots indexed 1 and 2. They are arranged as (1 2). Chef goes to the first robot, gives him a cake, and moves to position 1. In the next step, he sees that robot at this position already has a has cake. So Chef stops moving, and our answer is "No 1".
In test case 2, we again have two robots indexed 1 and 2. Initially, they are arranged as (1 2). Then, Chef moves robot#1 to the end of the row, and thus the arrangement becomes (2 1). Chef goes to the robot at the first position, which is robot#2. Chef hands him a cake, and moves to position 2. Then, he hands a cake to robot#1 at position 2, and moves back to the first position. Since, robot#2 at the first position already ahs a cake, Chef stops moving. All N robots have cakes, so Chef is satisfied, and our answer is "Yes".
In the 3rd test case, we have the following arrangement of robots: (3 4 1 2). Only robots with indices 3 and 1 will get cakes. So our answer is "No 2".

Starter code:

Solutions:
#read input
cases = int(input())
caselist = []
for i in range(0, cases):
 caselist.append(input())

#iterate each case
for j in range(0, cases):

 #current case's parameters:
 current_input = caselist[j].split(' ')
 bots = int(current_input[0])
 switch = int(current_input[1])

 #generate botlist and cakelist
 botlist = list(range(switch, bots)) + list(range(0, switch))
 cakelist = [False] * bots


 counter = 0
 index = 0
 for i in range(0,bots):
  if cakelist[index] == False:
   cakelist[index] = True
   counter += 1
   index = botlist[index]
  else:
   break

 if counter == bots:
  print("Yes")
 else:
  print("No", counter)
  

 


def ggt(a, b):
 while b != 0:
  c = a % b
  a = b
  b = c
 return a

def kgv(a, b):
 return (a * b) / ggt(a, b)


case = int(input())

for l in range(case):
 n, k = list(map(int, input().split()))
 if n == 1:
  print("Yes")
 elif k == 0:
  print("No 1") 
 else:   
  remaining = kgv(n, k)/k
  if remaining == n:
   print("Yes") 
  
  else:
   print("No %d" % remaining)
 


 


import array
T = int(input())
for _ in range(T):
 N,M = list(map(int,input().split()))
 robots = array.array('I')
 robots.extend((0,)*((N>>5)+1))
 c = 0
 Id = M
 while robots[Id>>5] & (1 << (Id&31))==0:
  robots[Id>>5]+=1<<(Id&31)
  c+=1
  Id = (Id+M)%N
 if c==N:
  print("Yes")
 else:
  print("No",c)

import fractions

def eval(n, m):
 g = fractions.gcd(n, m)

 if g == n:
  if n == 1:
   print("Yes")
  else:
   print("No 1")
 elif g == 1:
  print("Yes")
 else:
  print("No %d" % (n / g))

t = int(input())

for _ in range(t):
 (n, m) = [int(x) for x in input().split()]
 eval(n, m)


T = int(input())
for _ in range(T):
 N,M = list(map(int,input().split()))
 robots = [0]*N
 c = 0
 Id = M
 while robots[Id]!=1:
  robots[Id]=1
  c+=1
  Id = (Id+M)%N
 if c==N:
  print("Yes")
 else:
  print("No",c)

def idat(pos,M,N):
 return (pos+M)%N

T = eval(input())
for _ in range(T):
 N,M = list(map(int,input().split(" ")))
 robots = [0]*N
#     print range(1,N+1)[M:]+range(1,N+1)[:M]
 Id = idat(0,M,N)
 while robots[Id]!=1:
  robots[Id]=1
  newpos = Id
  Id = idat(newpos,M,N)
#         print robots[M:]+robots[:M]
 if robots.count(1)==N:
  print("Yes")
 else:
  print("No",robots.count(1))

def gcd(n,m):
 if m==0:
  return n
 else:
  return gcd(m,n%m)
t=int(input())
while t:
 par=[int(i) for i in input().split(' ')]
 n,m=par[0],par[1]
 g_div=gcd(n,m)
 if g_div==1:
  print("Yes")
 else:
  print("No "+str(int(n/g_div)))
 t=t-1


t=int(input())
while t>0:
 t-=1
 l=input().split(' ')
 m=int(l[0])
 n=int(l[1])
 k=n+1
 c=1
 while k!=1:
  c+=1
  k=n+k
  if k>m:
   k=k-m
 if c==m:
  print("Yes")
 else:
  print("No",c)


def ggt(a, b):
 while b != 0:
  c = a % b
  a, b = b, c
 return a

def kgv(a, b):
 return (a * b) / ggt(a, b)


case = int(input())

for l in range(case):
 n, k = list(map(int, input().split()))
 if n == 1:
  print("Yes")
 elif k == 0:
  print("No 1") 
 else:   
  cak = kgv(n, k)/k
  if cak == n:
   print("Yes") 
  
  else:
   print("No %d" % cak)
 


 


# your code goes here
t = eval(input())

for i in range(t):
 n,m = list(map(int, input().split()))
 hsck = 0
 z = list(range(1,n+1))
 
 
 z = z[m:]+z[:m]
 
 arr = {j:0 for j in z}
 
 y = z[0]
 while arr[y]!=1:
  arr[y] = 1
  y = z[y-1]
 c = 0
 for j in list(arr.keys()):
  c+=arr[j]
 
 if c==n:
  print('Yes')
 else:
  print('No',c)
 


import numpy as np

t=int(input())
while(t):
 t-=1
 n,m=list(map(int,input().split()))
 '''
    a=range(1,n+1)
    if m!=0:
     a=a[m:]+a[:m]
    ''' 
 b=np.zeros(n,dtype='bool')
 
 
 #print b
 pos=0
 while(True):
  if b[(pos+m)%n]==True:
   break
  else:
   b[(pos+m)%n]=True
   pos=(pos+m)%n
   
  #print b,pos    
 
 s=sum(b)
 if s==n:
  print('Yes')
 else:
  print('No'+' '+str(s))

for i in range(int(input())):
 l = [int(j) for j in input().split()]
 n, m = l[0], l[1]
 count = 0
 j = 1
 while j <= n:
  j = j + m
  if j > n:
   j = j - n
  count += 1
  if j == 1:
   break
 if count == n:
  print('Yes')
 else:
  print('No ' + str(count))

for i in range(int(input())):
 l = [int(j) for j in input().split()]
 n, m = l[0], l[1]
 idx = 0
 count = 0
 arr = []
 for j in range(m, n):
  arr.append(j + 1)
 for j in range(m):
  arr.append(j + 1)
 for j in range(n):
  idx = (arr[idx] - 1)
  count += 1
  if idx == 0:
   break
 if count == n:
  print('Yes')
 else:
  print('No ' + str(count))

import sys
T=int(input())
while T>0:
 t=sys.stdin.readline().split()
 N=int(t[0])
 M=int(t[1])
 A=[i for i in range(1,N+1)]
 A=A[M:]+A[0:M]
 count=1
 flag=True
 i=A[0]-1
 A[0]=(-1)*A[0]
 while (flag and (count<N)):
  if A[i]<0:
   flag=False
  else:
   j=A[i]-1
   A[i]=(-1)*A[i]
   i=j
   count+=1
 if not flag:
  print('No',count)
 else:
  print('Yes')
 T=T-1


T=int(input())
while T>0:
 N,M=list(map(int,input().strip().split()))
 A=[i for i in range(1,N+1)]
 A=A[M:]+A[0:M]
 count=1
 flag=True
 i=A[0]-1
 A[0]=(-1)*A[0]
 while (flag and (count<N)):
  if A[i]<0:
   flag=False
  else:
   j=A[i]-1
   A[i]=(-1)*A[i]
   i=j
   count+=1
 if not flag:
  print('No',count)
 else:
  print('Yes')
 T=T-1


n=list(map(int,input().split()))
g=[]
l=[]
for i in range(n[0]):
 m=[]
 l=list(map(int,input().split()))
 for j in range(l[1]+1,l[0]+1):
  m.append(j)
 for j in range(1,l[1]+1):
  m.append(j) 
 c=0
 f=0
 d={}
 for j in range(0,len(m)):
  if f not in d:d[f]="No"
  if d[f]=="Yes":
   break
  else:
   d[f]="Yes"
   f=m[f]-1
  c=c+1
 if c==len(m):
  g.append("Yes")
 else:
  g.append("No"+" "+str(c))
for i in range(len(g)):
 print(g[i])