Problem: 3np1

Problem ID3np1
Difficulty level (0..10)3
Maximum runtime1 minute
Original problem
Seen atInternet Contest 90

The 3n+1 problem

Using the following algorithm:

1. input n
2. print n
3. if n=1 then stop
4. if n is odd then n <- 3n+1
5. else n <- n / 2
6. goto 2
Given the number i.e. 22 we have:
22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
in 16 steps. 16 is the cycle length of 22. For any i and j one can find the maximum cycle-length of all the numbers between and including i and j.

Input will consist of pairs of i and j, one pair at a line. i and j will be less than 10000 and greater than 0. At the output i and j with the maximum cycle-length of all integers between and including i and j pairs should be printed. One line for each pair. i and j should be printed in the same order as in the input. No trailing or leading spaces. No more than one space between the output numbers.

Sample input:

1 10
100 200
201 210
900 1000

Sample output:

1 10 20
100 200 125
201 210 89
900 1000 174