A scientist discovered a strange variation of amoeba. The scientist named it numoeba. A numoeba, though it looks like an amoeba, is actually a community of cells, which always forms a tree.

The scientist called the cell leader that is at the root position of the tree. For example, in Fig. 1, the leader is A. In a numoeba, its leader may change time to time. For example, if E gets new leadership, the tree in Fig. 1 becomes one in Fig. 2. We will use the terms root, leaf, parent, child and subtree for a numoeba as defined in the graph theory.

<image>

Numoeba changes its physical structure at every biological clock by cell division and cell death. The leader may change depending on this physical change.

The most astonishing fact about the numoeba cell is that it contains an organic unit called numbosome, which represents an odd integer within the range from 1 to 12,345,677. At every biological clock, the value of a numbosome changes from n to a new value as follows:

1. The maximum odd factor of 3n + 1 is calculated. This value can be obtained from 3n + 1 by repeating division by 2 while even.
2. If the resulting integer is greater than 12,345,678, then it is subtracted by 12,345,678.



For example, if the numbosome value of a cell is 13, 13 × 3 + 1 = 40 is divided by 23 = 8 and a new numbosome value 5 is obtained. If the numbosome value of a cell is 11,111,111, it changes to 4,320,989, instead of 16,666,667. If 3n + 1 is a power of 2, yielding 1 as the result, it signifies the death of the cell as will be described below.

At every biological clock, the next numbosome value of every cell is calculated and the fate of the cell and thereby the fate of numoeba is determined according to the following steps.

1. A cell that is a leaf and increases its numbosome value is designated as a candidate leaf.
A cell dies if its numbosome value becomes 1. If the dying cell is the leader of the numoeba, the numoeba dies as a whole. Otherwise, all the cells in the subtree from the dying cell (including itself) die. However, there is an exceptional case where the cells in the subtree do not necessarily die; if there is only one child cell of the dying non-leader cell, the child cell will replace the dying cell. Thus, a straight chain simply shrinks if its non-leader constituent dies.
For example, consider a numoeba with the leader A below.

<image>
If the leader A dies in (1), the numoeba dies.
If the cell D dies in (1), (1) will be as follows.

<image>
And, if the cell E dies in (1), (1) will be as follows.

<image>
Note that this procedure is executed sequentially, top-down from the root of the numoeba to leaves. If the cells E and F will die in (1), the death of F is not detected at the time the procedure examines the cell E. The numoeba, therefore, becomes (3). One should not consider in such a way that the death of F makes G the only child of E, and, therefore, G will replace the dying E.
2. If a candidate leaf survives with the numbosome value of n, it spawns a cell as its child, thereby a new leaf, whose numbosome value is the least odd integer greater than or equal to (n + 1)/2. We call the child leaf bonus.
3. Finally, a new leader of the numoeba is selected, who has a unique maximum numbosome value among all the constituent cells. The tree structure of the numoeba is changed so that the new leader is its root, like what is shown in Fig. 1 and Fig. 2. Note that the parent-child relationship of some cells may be reversed by this leader change. When a new leader of a unique maximum numbosome value, say m, is selected (it may be the same cell as the previous leader), it spawns a cell as its child with the numbosome whose value is the greatest odd integer less than or equal to (m + 1)/2. We call the child leader bonus. If there is more than one cell of the same maximum numbosome value, however, the leader does not change for the next period, and there is no leader bonus.



The following illustrates the growth and death of a numoeba starting from a single cell seed with the numbosome value 15, which plays both roles of the leader and a leaf at the start. In the figure, a cell is nicknamed with its numbosome value. Note that the order of the children of a parent is irrelevant.


<image>
<image>


The numoeba continues changing its structure, and at clock 104, it looks as follows.


<image>



Here, two ambitious 2429's could not become the leader. The leader 5 will die without promoting these talented cells at the next clock. This alludes the fragility of a big organization.

And, the numoeba dies at clock 105.

Your job is to write a program that outputs statistics about the life of numoebae that start from a single cell seed at clock zero.



Input

A sequence of odd integers, each in a line. Each odd integer ki (3 ≤ ki ≤ 9,999) indicates the initial numbosome value of the starting cell. This sequence is terminated by a zero.

Output

A sequence of pairs of integers:an integer that represents the numoeba's life time and an integer that represents the maximum number of constituent cells in its life. These two integers should be separated by a space character, and each pair should be followed immediately by a newline. Here, the lifetime means the clock when the numoeba dies.

You can use the fact that the life time is less than 500, and that the number of cells does not exceed 500 in any time, for any seed value given in the input. You might guess that the program would consume a lot of memory. It is true in general. But, don't mind. Referees will use a test data set consisting of no more than 10 starting values, and, starting from any of the those values, the total numbers of cells spawned during the lifetime will not exceed 5000.

Example

Input

3
5
7
15
655
2711
6395
7195
8465
0


Output

2 3
1 1
9 11
105 65
398 332
415 332
430 332
428 332
190 421

#include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;

const int MOD = 12345678;
const int NIL = -1;

class Numoeba {
public:
    Numoeba(const int n) :max_cell_(1), root_(0) {create_cell(n);}
    tuple<int, int> die() {
        for(int step = 1; step <= 500; ++step) {
            int t = dead_.size() - count(dead_.begin(), dead_.end(), true);
            max_cell_ = max(max_cell_, t);
            vector<int> candidate;
            int new_leader_id, new_leader_n = NIL;
// cout<<step<<endl;
// cout<<"root: "<<root_<<endl;
// cout<<"dead: ";for(const auto&d:dead_)cout<<" "<<d;cout<<endl;
// cout<<"numb: ";for(const auto&d:numbosome_)cout<<" "<<d;cout<<endl;
            if(traverse(root_, NIL, candidate, new_leader_id, new_leader_n)) return tuple<int, int>(step, max_cell_);
            for(auto& e: edge_) for(int i = 0; i < e.size(); ++i) if(dead_[e[i]]) e.erase(e.begin() + i--);
// cout<<"candidate: ";for(const auto&d:candidate)cout<<" "<<d;cout<<endl;
            for(const auto& c: candidate) {
                int n = (numbosome_[c] + 1) / 2;
                if(!(n & 1)) ++n;
//                 if(n <= 1) continue;
//                 if(dead_[c]) continue;
                add_child(c, create_cell(n));
            }
            if(new_leader_id == NIL) continue;
            root_ = new_leader_id;
            int n = (numbosome_[root_] + 1) / 2;
            if(!(n & 1)) --n;
//             if(n <= 1) continue;
            add_child(root_, create_cell(n));
        }
        return tuple<int, int>(NIL, max_cell_);
    }
private:
    bool traverse(const int current, const int previous, vector<int>& candidate, int& new_leader_id, int& new_leader_n) {
        int pn = numbosome_[current];
        if(update(current) == 1) {
            dead_[current] = true;
            if(current == root_) return true;
            if(edge_[current].size() == 2) {
                int next = edge_[current][0];
                if(next == previous) next = edge_[current][1];
                for(auto& id: edge_[previous]) if(id == current) id = next;
                for(auto& id: edge_[next]) if(id == current) id = previous;
                return traverse(next, previous, candidate, new_leader_id, new_leader_n);
            }
            for(const auto& next: edge_[current]) if(next != previous) erase(next, current);
            return false;
        }
        if(numbosome_[current] > pn && edge_[current].size() <= 1) candidate.push_back(current);
        if(numbosome_[current] == new_leader_n) new_leader_id = NIL;
        if(numbosome_[current] > new_leader_n) {
            new_leader_n = numbosome_[current];
            new_leader_id = current;
        }
        for(const auto& next: edge_[current]) {
            if(next == previous) continue;
            if(traverse(next, current, candidate, new_leader_id, new_leader_n)) return true;
        }
        return false;
    }
    void erase(const int current, const int previous) {
        dead_[current] = true;
        for(const auto& next: edge_[current]) if(next != previous) erase(next, current);
    }
    int create_cell(const int n) {
        numbosome_.push_back(n);
        dead_.push_back(false);
        edge_.push_back(vector<int>());
        return (dead_.size() - 1);
    }
    void add_child(const int pid, const int cid) {
        edge_[pid].push_back(cid);
        edge_[cid].push_back(pid);
    }
    int update(const int id) {
        numbosome_[id] = numbosome_[id] * 3 + 1;
        while(!(numbosome_[id] & 1)) numbosome_[id] >>= 1;
        if(numbosome_[id] > MOD) numbosome_[id] -= MOD;
//         while(numbosome_[id] > MOD) numbosome_[id] -= MOD;
        return numbosome_[id];
    }
    int root_;
    int max_cell_;
    vector<int> numbosome_;
    vector<bool> dead_;
    vector<vector<int>> edge_;
public:
void print(){
cout<<"root: "<<root_<<endl;
cout<<"dead: ";for(const auto&d:dead_)cout<<" "<<d;cout<<endl;
cout<<"numb: ";for(const auto&d:numbosome_)cout<<" "<<d;cout<<endl;
cout<<dead_.size()<<endl;
}
};


int main() {
    int k;
    while(cin >> k, k) {
        Numoeba n(k);
        int step, numbosome;
        tie(step, numbosome) = n.die();
        cout << step << " " << numbosome << endl;
//         n.print();
    }
}