BINPALI - Binary Palindromes Set

no tags 

 

Write a program to find out all the numbers whose binary value is a palindrome . Your input will be the number of test cases and for each test case the range of numbers to check for palindrome i.e. the start and end value of the range. Your output will display all the numbers whose binary value is a palindrome. One line of output for each test case.

 

Given two integers A and B, write a program to find out all the numbers whose binary value is a palindrome in that range. Your input will be the range of numbers to check for palindrome i.e. the start and end value of the range. Your output will display all the numbers whose binary value is a palindrome. It is also important to note that you shall treat a binary number as palindrome, only while considering the minimum no of bits required to represent the number. In other words, ignore all leading zeros. E.g. 6, which can be represented as 0110 is not a palindrome, because if you ignore the leading zeroes, you have only 110.

 

 

Input

First line of input is no. of test cases T. T lines of input follow, each having 2 integers A and B. A and B denote the upper and lower limit of your range (both inclusive) for the problem.

0<=T<=10000

0<=A,B<=2147483647

Output

For each test case, print it's output in a new line. When there are more than 1 integers in the answer, print them separated by a single space in ascending order. If there is no answer, just print "none".

 

Example

Input:
2
3 7
10 14

Output:
3 5 7
none

hide comments
xol odho: 2012-04-07 08:26:36

my program seems to deliver correct results when I run it, but gets WA. I tried it on range 1~2147483647 and works (all numbers are binary palindromes), and none seems missing. I don't know what could be wrong.


Added by:Ali Asgar
Date:2011-10-14
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ADA95 ASM32 ASM64 BASH BF C99 CLPS CLOJURE LISP sbcl LISP clisp D ERL FSHARP FORTRAN GO HASK ICON ICK JS-RHINO LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PERL6 PHP PIKE PRLG-swi RUBY SCALA SCM guile SCM qobi ST TCL WHITESPACE
Resource:ACM Student Chapter Contest