http://acm.hdu.edu.cn/showproblem.php?pid=1406
/*
2011-9-16
author:BearFly1990
*/
package acm.hdu.tests;
import java.io.BufferedInputStream;
import java.util.Scanner;
public class HDU_1406 {
private static Integer[] perfectNum={6,28,496,8128};
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedInputStream(System.in));
while(in.hasNext()){
Integer t = in.nextInt();
while(t-- > 0){
Integer begin = in.nextInt();
Integer end = in.nextInt();
if(begin > end){
int temp = begin;
begin = end ;
end = temp;
}
// begin ^= end ^= begin ^= end;
Integer cnt = 0;
for(int j = 0; j < 4; j++){
if(begin <= perfectNum[j] && perfectNum[j] <= end){
cnt++;
}
}
System.out.println(cnt);
}
}
}
}