/* Problem 4--Divisors
   This was very straightforward. */

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char **argv);

int main (int argc, char **argv) {

  int r, cs, i, j, k, a, b, m, mj, ct, jj, jct;
  FILE *in, *out;

 in = fopen ("prob4.in","r");
 out = fopen ("prob4.out","w");
 fscanf (in,"%d",&cs); /* Get number of cases */
 i = 0;
 for (;;) {
 if (i==cs) break;
  fscanf (in,"%d %d",&a,&b); /* get two numbers */
  m = mj = 0;
  j = a;
  for (;;) { /* For each number in range */
  if (j > b) break;
   jj = j;
   k = 2;
   ct = 1;
   for (;;) { /*compute the number of times a certain prime divides it*/
   if (k*k > jj) break;
    jct = 0;
    for (;;) {
    if (jj % k > 0) break;
     jct++;
     jj /= k; /* remove that prime factor */
    }
    ct *= jct+1;
    k++;
   }
   if (jj > 1) { /* Is there a prime remaining? */
    ct *= 2;
   } else {
   }
   if (ct > m) { /* Update maximum */
    m = ct;
    mj = j;
   } else {
   }
   j++;
  }
  fprintf (out,"Between %d and %d, %d has a maximum of %d divisors.\n",
               a,b,mj,m);
  i++;
 }
 fclose (in);
 fclose (out);
 r = EXIT_SUCCESS;
 return r;
}

