Problem: Problem Statement

Let b_i(x) be the i-th least significant bit of x, i.e. the i-th least significant digit of x in base 2 (i \geq 1). For example, since 6 = (110)_2, b_1(6) = 0, b_2(6) = 1, b_3(6) = 1, b_4(6) = 0, b_5(6) = 0, and so on.

Let A and B be integers that satisfy 1 \leq A \leq B \leq 10^{18}, and k_i be the number of integers x such that A \leq x \leq B and b_i(x) = 1.

Your task is to write a program that determines A and B for a given \\{k_i\\}.



Input

The input consists of multiple datasets. The number of datasets is no more than 100,000. Each dataset has the following format:


n
k_1
k_2
...
k_n


The first line of each dataset contains an integer n (1 \leq n \leq 64). Then n lines follow, each of which contains k_i (0 \leq k_i \leq 2^{63} - 1). For all i > n, k_i = 0.

The input is terminated by n = 0. Your program must not produce output for it.

Output

For each dataset, print one line.

* If A and B can be uniquely determined, output A and B. Separate the numbers by a single space.
* If there exists more than one possible pair of A and B, output `Many` (without quotes).
* Otherwise, i.e. if there exists no possible pair, output `None` (without quotes).

Example

Input

3
2
2
1
49
95351238128934
95351238128934
95351238128932
95351238128936
95351238128936
95351238128936
95351238128960
95351238128900
95351238128896
95351238129096
95351238128772
95351238129096
95351238129096
95351238126156
95351238131712
95351238131712
95351238149576
95351238093388
95351238084040
95351237962316
95351238295552
95351237911684
95351237911684
95351235149824
95351233717380
95351249496652
95351249496652
95351226761216
95351226761216
95351082722436
95351082722436
95352054803020
95352156464260
95348273971200
95348273971200
95354202286668
95356451431556
95356451431556
95346024826312
95356451431556
95356451431556
94557999988736
94256939803780
94256939803780
102741546035788
87649443431880
87649443431880
140737488355328
32684288648324
64
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
11
0
0
1
1
1
0
1
1
1
1
1
63
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
4
1
1
1
1
0


Output

1 4
123456789101112 314159265358979
None
2012 2012
None
Many

Solution (in CPP):

Solution:
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const long long BAR = 1000000000000000000ll;
pair<long long, long long> MANY, NONE;
int n;

inline bool isValid(pair<long long, long long> a) {
    return a != NONE && a != MANY;
}

long long num(int i, long long a) {
    return (a >> (i + 1) << i) + (a >> i & 1) * ((a & ((1ll << i) - 1)) + 1);
}

pair<long long, long long> calc(vector<long long> a) {
    vector<long long> bak = a;
    int n = a.size();
    long long A, B;
    B = (1ll << (n - 1)) + a.back() - 1;
    for (int i = 0; i < n; ++i) {
        a[i] -= num(i, a.back() - 1);
    }
    A = (1ll << (n - 1));
    for (int i = n - 2; i >= 0; --i) {
//cout << "for" << ' ' << i << ' ' << a[i] << endl;
        if (a[i] < 0 || a[i] > (1ll << i)) {
            return NONE;
        }
        if (a[i] < (1ll << i)) {
            A -= a[i];
            break;
        }
        A -= a[i];
        for (int j = 0; j < i; ++j) {
            a[j] -= 1ll << (i - 1);
        }
    }
//cout << A << ' ' << B << endl;
    for (int i = 0; i < n; ++i) {
//cout << "cut" << ' ' << i << ' ' << num(i, B) - num(i, A - 1) << endl;
        if (num(i, B) - num(i, A - 1) != bak[i]) {
            return NONE;
        }
    }
    return make_pair(A, B);
}

vector<pair<long long, long long> > solve(vector<long long> a) {
    vector<pair<long long, long long> > ret;
    if (a.size() == 1) {
        ret.push_back(a.back() ? make_pair(1, 1) : make_pair(0, 0));
        return ret;
    }
    if (a.back() == 0) {
        a.pop_back();
        return solve(a);
    }
    int n = a.size();
    if (a.back() > 1ll << (n - 1)) {
        return ret;
    }
    vector<pair<long long, long long> > tmp, ansg;
    pair<long long, long long> ans;
    ans = calc(a);
    if (isValid(ans)) {
       ansg.push_back(ans);
    }
    long long d = a.back();
    a.pop_back();
    tmp = solve(a);
    for (int i = 0; i < (int)tmp.size(); ++i) {
        ans = tmp[i];
        if (ans.second - ans.first + 1 != d) {
            continue;
        }
        ans.first += 1ll << (n - 1);
        ans.second += 1ll << (n - 1);
        ansg.push_back(ans);
    }
    sort(ansg.begin(), ansg.end());
    ansg.erase(unique(ansg.begin(), ansg.end()), ansg.end());
    return ansg;
}

int main() {
    MANY = make_pair(-1, -1);
    NONE = make_pair(-2, -2);
    while (scanf("%d", &n) == 1 && n) {
        vector<long long> s;
        for (int i = 0; i < n; ++i) {
            long long a;
            scanf("%lld", &a);
            s.push_back(a);
        }
        bool flag = false;
        for (int i = 64; i >= 60; --i) {
            if (n > i && s[i] > 0) {
                flag = true;
            }
        }
        if (flag) {
            printf("None\n");
            continue;
        }
        vector<pair<long long, long long> > ans, tmp = solve(s);
        sort(tmp.begin(), tmp.end());
        tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
        for (int i = 0; i < (int)tmp.size(); ++i) {
            if (tmp[i].second > BAR || tmp[i].first <= 0) {
                continue;
            }
            ans.push_back(tmp[i]);
        }
        if (ans.size() == 0) {
            printf("None\n");
        } else if (ans.size() > 1) {
            printf("Many\n");
        } else {
            printf("%lld %lld\n", ans[0].first, ans[0].second);
        }
    }
    return 0;
}