Problem: You have a full binary tree having infinite levels.

Each node has an initial value. If a node has value x, then its left child has value 2·x and its right child has value 2·x + 1. 

The value of the root is 1. 

You need to answer Q queries. 

There are 3 types of queries: 

  1. Cyclically shift the values of all nodes on the same level as node with value X by K units. (The values/nodes of any other level are not affected).
  2. Cyclically shift the nodes on the same level as node with value X by K units. (The subtrees of these nodes will move along with them).
  3. Print the value of every node encountered on the simple path from the node with value X to the root.



Positive K implies right cyclic shift and negative K implies left cyclic shift. 

It is guaranteed that atleast one type 3 query is present.

Input

The first line contains a single integer Q (1 ≤ Q ≤ 105).

Then Q queries follow, one per line: 

  * Queries of type 1 and 2 have the following format: T X K (1 ≤ T ≤ 2; 1 ≤ X ≤ 1018; 0 ≤ |K| ≤ 1018), where T is type of the query.
  * Queries of type 3 have the following format: 3 X (1 ≤ X ≤ 1018).

Output

For each query of type 3, print the values of all nodes encountered in descending order.

Examples

Input

5
3 12
1 2 1
3 12
2 4 -1
3 8


Output

12 6 3 1 
12 6 2 1 
8 4 2 1 


Input

5
3 14
1 5 -3
3 14
1 3 1
3 14


Output

14 7 3 1 
14 6 3 1 
14 6 2 1 

Note

Following are the images of the first 4 levels of the tree in the first test case:

Original: 

<image>

After query 1 2 1: 

<image>

After query 2 4 -1: 

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using SI = set<int>;
using ULL = unsigned long long;
using LL = long long;
using VI = vector<int>;
using LD = long double;
using PULL = pair<ULL, ULL>;
using UI = unsigned int;
using PLL = pair<LL, LL>;
using PDD = pair<LD, LD>;
using MII = map<int, int>;
using TDD = pair<PDD, LD>;
using TLL = pair<PLL, LL>;
using PII = pair<int, int>;
using TII = pair<PII, int>;
using QDD = pair<PDD, PDD>;
using QII = pair<PII, PII>;
using QLL = pair<PLL, PLL>;
using STII = set<TII>;
using VTII = vector<TII>;
using MTII = map<TII, TII>;
using MITII = map<int, TII>;
using UMITII = unordered_map<int, TII>;
using SQII = set<QII>;
using VQII = vector<QII>;
using MQII = map<QII, QII>;
using MIQII = map<int, QII>;
using UMIQII = unordered_map<int, QII>;
using SLL = set<LL>;
using VLL = vector<LL>;
using MLL = map<LL, LL>;
using MILL = map<int, LL>;
using UMILL = unordered_map<int, LL>;
using SULL = set<ULL>;
using VULL = vector<ULL>;
using MULL = map<ULL, ULL>;
using MIULL = map<int, ULL>;
using UMIULL = unordered_map<int, ULL>;
using SPULL = set<PULL>;
using VPULL = vector<PULL>;
using MPULL = map<PULL, PULL>;
using MIPULL = map<int, PULL>;
using UMIPULL = unordered_map<int, PULL>;
using SQLL = set<QLL>;
using VQLL = vector<QLL>;
using MQLL = map<QLL, QLL>;
using MIQLL = map<int, QLL>;
using UMIQLL = unordered_map<int, QLL>;
using SLD = set<LD>;
using VLD = vector<LD>;
using MLD = map<LD, LD>;
using MILD = map<int, LD>;
using UMILD = unordered_map<int, LD>;
using SPDD = set<PDD>;
using VPDD = vector<PDD>;
using MPDD = map<PDD, PDD>;
using MIPDD = map<int, PDD>;
using UMIPDD = unordered_map<int, PDD>;
using SVI = set<VI>;
using VVI = vector<VI>;
using MVI = map<VI, VI>;
using MIVI = map<int, VI>;
using UMIVI = unordered_map<int, VI>;
using STLL = set<TLL>;
using VTLL = vector<TLL>;
using MTLL = map<TLL, TLL>;
using MITLL = map<int, TLL>;
using UMITLL = unordered_map<int, TLL>;
using SUI = set<UI>;
using VUI = vector<UI>;
using MUI = map<UI, UI>;
using MIUI = map<int, UI>;
using UMIUI = unordered_map<int, UI>;
using SPII = set<PII>;
using VPII = vector<PII>;
using MPII = map<PII, PII>;
using MIPII = map<int, PII>;
using UMIPII = unordered_map<int, PII>;
using SPLL = set<PLL>;
using VPLL = vector<PLL>;
using MPLL = map<PLL, PLL>;
using MIPLL = map<int, PLL>;
using UMIPLL = unordered_map<int, PLL>;
using SSI = set<SI>;
using VSI = vector<SI>;
using MSI = map<SI, SI>;
using MISI = map<int, SI>;
using UMISI = unordered_map<int, SI>;
using SVVI = set<VVI>;
using VVVI = vector<VVI>;
using MVVI = map<VVI, VVI>;
using MIVVI = map<int, VVI>;
using UMIVVI = unordered_map<int, VVI>;
using UMII = unordered_map<int, int>;
ULL randULL() {
  return ((ULL)rand()) ^ ((ULL)rand() << 15) ^ ((ULL)rand() << 30) ^
         ((ULL)rand() << 45) ^ ((ULL)rand() << 60);
}
using STDD = set<TDD>;
using VTDD = vector<TDD>;
using MTDD = map<TDD, TDD>;
using MITDD = map<int, TDD>;
using UMITDD = unordered_map<int, TDD>;
using SQDD = set<QDD>;
using VQDD = vector<QDD>;
using MQDD = map<QDD, QDD>;
using MIQDD = map<int, QDD>;
using UMIQDD = unordered_map<int, QDD>;
int popc(int x) { return __builtin_popcount(x); }
int popc(UI x) { return __builtin_popcount(x); }
int popc(LL x) { return __builtin_popcountll(x); }
int popc(ULL x) { return __builtin_popcountll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(UI x) { return __builtin_ctz(x); }
int ctz(LL x) { return __builtin_ctzll(x); }
int ctz(ULL x) { return __builtin_ctzll(x); }
int clz(int x) { return __builtin_clz(x); }
int clz(UI x) { return __builtin_clz(x); }
int clz(LL x) { return __builtin_clzll(x); }
int clz(ULL x) { return __builtin_clzll(x); }
int bit_parity(int x) { return __builtin_parity(x); }
int bit_parity(UI x) { return __builtin_parity(x); }
int bit_parity(LL x) { return __builtin_parityll(x); }
int bit_parity(ULL x) { return __builtin_parityll(x); }
template <class T, class U>
bool one_of(T x, U y) {
  return x == y;
}
template <class T, class U, class... V>
bool one_of(T x, U y, V... z) {
  return x == y || one_of(x, z...);
}
template <class T>
bool diff(T _) {
  return true;
}
template <class T, class... U>
bool diff(T x, U... y) {
  return !one_of(x, y...) && diff(y...);
}
template <class T, class U>
bool equal(T x, U y) {
  return x == y;
}
template <class T, class U, class... V>
bool equal(T x, U y, V... z) {
  return x == y && equal(x, z...);
}
template <class T, class U>
bool in_order(T x, U y) {
  return x <= y;
}
template <class T, class U, class... V>
bool in_order(T x, U y, V... z) {
  return x <= y && in_order(y, z...);
}
template <class T, class U>
bool in_strorder(T x, U y) {
  return x < y;
}
template <class T, class U, class... V>
bool in_strorder(T x, U y, V... z) {
  return x < y && in_strorder(y, z...);
}
template <class T>
void swap3(T &x, T &y, T &z) {
  swap(x, y);
  swap(x, z);
}
template <class T>
pair<T, T> dup(T x) {
  return make_pair(x, x);
}
template <class T>
pair<pair<T, T>, T> thrice(T x) {
  return make_pair(make_pair(x, x), x);
}
template <class T>
pair<pair<T, T>, pair<T, T>> fourfold(T x) {
  return make_pair(make_pair(x, x), make_pair(x, x));
}
template <class T, class U, class V>
T safvec(const vector<T> &v, int i, U low, V high) {
  if (i < 0) return low;
  if (i >= ((int)(v).size())) return high;
  return v[i];
}
template <class T, class U>
T safar(T *a, int i, U low) {
  if (i < 0) return low;
  return a[i];
}
template <class T, class U, class V>
auto med(const T &a, const U &b, const V &c) -> decltype(1 ? a : (1 ? b : c)) {
  return my_min(my_max(a, b), my_max(my_min(a, b), c));
}
namespace std {
template <class T, class U>
struct hash<pair<T, U>> {
  size_t operator()(const pair<T, U> &a) const {
    return (hash<T>()(a.first) * 1420343LL ^ hash<U>()(a.second) * 923275LL) %
           1463984161;
  }
};
}  // namespace std
template <class T, class U>
auto my_min(const U &x, const T &y) -> decltype(1 ? x : y) {
  return x < y ? x : y;
}
template <class T, class U>
bool mini(U &x, T y) {
  if (y < x) {
    x = y;
    return true;
  }
  return false;
}
template <class T, class U, class V>
auto my_min(const T &a, const U &b, const V &c)
    -> decltype(1 ? a : (1 ? b : c)) {
  return my_min(a, my_min(b, c));
}
template <class T, class U, class V, class W>
auto my_min(const T &a, const U &b, const V &c, const W &d)
    -> decltype(1 ? a : (1 ? b : (1 ? c : d))) {
  return my_min(a, my_min(b, c, d));
}
template <class T, class U>
auto my_max(const U &x, const T &y) -> decltype(1 ? x : y) {
  return x > y ? x : y;
}
template <class T, class U>
bool maxi(U &x, T y) {
  if (y > x) {
    x = y;
    return true;
  }
  return false;
}
template <class T, class U, class V>
auto my_max(const T &a, const U &b, const V &c)
    -> decltype(1 ? a : (1 ? b : c)) {
  return my_max(a, my_max(b, c));
}
template <class T, class U, class V, class W>
auto my_max(const T &a, const U &b, const V &c, const W &d)
    -> decltype(1 ? a : (1 ? b : (1 ? c : d))) {
  return my_max(a, my_max(b, c, d));
}
template <class T>
T brange(int l, int r) {
  return ~(~((T)0) << (r - l + 1)) << l;
}
template <class T>
T brange(int l, int r, int second) {
  return (brange<T>(l, l + (r - l) / second * second - 1) /
          brange<T>(0, second - 1)) |
         ((T)1 << (l + (r - l) / second * second));
}
template <class T>
auto O2kQ(T x, int i, int j)
    -> vector<typename remove_reference<decltype(*x.end())>::type> {
  vector<typename remove_reference<decltype(*x.end())>::type> ans;
  for (auto c : x)
    if ((--i < 0) & (j-- >= 0)) ans.push_back(c);
  return ans;
}
template <class T>
vector<T> O2kQ(const T *x, int i, int j) {
  vector<T> ans;
  for (int _ = i; _ <= (int)(j); _++) ans.push_back(x[_]);
  return ans;
}
int CON_BOUND = 10;
string E0ms() { return ""; }
template <class T>
string E0ms(T x) {
  stringstream os;
  os << boolalpha << x;
  return os.str();
}
template <class T, class... U>
string E0ms(T x, U... y) {
  return E0ms(x) + ", " + E0ms(y...);
}
string SqC6(bool x) { return x ? "true" : "false"; }
template <class T>
typename enable_if<is_integral<T>::value, string>::type SqC6(T r) {
  string a;
  for (int i = 8 * sizeof(T) - 1; i >= (int)(0); i--) {
    if (i % 5 == 4) a += '.';
    a += '0' + !!(((T)1 << i) & r);
  }
  return a;
}
template <class T, class C>
string SqC6(pair<T, C>);
template <class T>
auto SqC6(T x) -> decltype(x.end(), string()) {
  string a = "";
  for (auto c : x) {
    if (((int)(a).size())) a += ", ";
    a += SqC6(c);
  }
  return "{" + a + "}_" + to_string(((int)(x).size()));
}
template <class T, class C>
string SqC6(pair<T, C> x) {
  return "<" + SqC6(x.first) + ", " + SqC6(x.second) + ">";
}
template <class T, int N>
T &arrp(T a[][N], PII x) {
  return a[x.first][x.second];
}
const int mod = 1e9 + 7;
LL mpow(LL b, int e) {
  LL ans = 1;
  while (e) {
    if (e & 1) ans = ans * b % mod;
    b = b * b % mod;
    e /= 2;
  }
  return ans;
}
struct zet_p {
  int v;
  int get() { return v; }
  zet_p(LL x = 0) { v = x % mod; }
  zet_p operator+(zet_p x) { return (v + x.v) % mod; }
  zet_p operator-(zet_p x) { return v - x.v; }
  zet_p operator*(zet_p x) { return v * 1ll * x.v; }
  zet_p operator/(zet_p a) { return v * mpow(a.v, mod - 2); }
};
const bool deb = false;
struct frac_mod {
  int n, d;
  frac_mod(int x = 0) {
    n = x % mod;
    d = 1;
  }
  frac_mod(int x, int y) {
    n = x;
    d = y;
  }
  frac_mod operator+(frac_mod x) {
    return {(int)((x.d * 1ll * n + d * 1ll * x.n) % mod), x.d * d % mod};
  }
  frac_mod operator-(frac_mod x) {
    return {(int)((n * 1ll * x.d - x.n * 1ll * d) % mod), x.d * d % mod};
  }
  frac_mod operator*(frac_mod x) {
    return {(int)((n * (LL)x.n) % mod), (int)((d * (LL)x.d) % mod)};
  }
  frac_mod operator/(frac_mod x) {
    return {(int)(n * (LL)x.d % mod), (int)(d * (LL)x.n % mod)};
  }
  int get() {
    int ans = n * mpow(d, mod - 2) % mod;
    if (ans < 0) ans += mod;
    return ans;
  }
};
template <class T>
typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator+(
    frac_mod x, T y) {
  return x + frac_mod(y);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator+(
    T x, frac_mod y) {
  return frac_mod(x) + y;
}
template <class T>
frac_mod &operator+=(frac_mod &x, T y) {
  return x = x + y;
}
template <class T>
typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator-(
    frac_mod x, T y) {
  return x - frac_mod(y);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator-(
    T x, frac_mod y) {
  return frac_mod(x) - y;
}
template <class T>
frac_mod &operator-=(frac_mod &x, T y) {
  return x = x - y;
}
template <class T>
typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator*(
    frac_mod x, T y) {
  return x * frac_mod(y);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator*(
    T x, frac_mod y) {
  return frac_mod(x) * y;
}
template <class T>
frac_mod &operator*=(frac_mod &x, T y) {
  return x = x * y;
}
template <class T>
typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator/(
    frac_mod x, T y) {
  return x / frac_mod(y);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, frac_mod>::type operator/(
    T x, frac_mod y) {
  return frac_mod(x) / y;
}
template <class T>
frac_mod &operator/=(frac_mod &x, T y) {
  return x = x / y;
}
template <class T, class C>
ostream &operator<<(ostream &ans, pair<T, C> x) {
  return ans << "<" << x.first << ", " << x.second << ">";
}
template <class T>
auto operator<<(ostream &o, T x) ->
    typename enable_if<!is_same<T, string>::value, decltype(x.end(), o)>::type {
  o << "{";
  int i = 0;
  for (auto c : x) {
    if (i++ == ((int)(x).size()) - 1 || ((int)(x).size()) < CON_BOUND + 2 ||
        i < CON_BOUND) {
      if (i - 1 &&
          (i != ((int)(x).size()) || ((int)(x).size()) < CON_BOUND + 2))
        o << ", ";
      o << c;
    }
    if (i == CON_BOUND && ((int)(x).size()) > CON_BOUND + 1) o << " ... ";
  }
  return o << "}_" << x.size();
}
string b7Pe(string x) {
  int dep = 0;
  for (char c : x) {
    for (char d : "([{")
      if (c == d) dep++;
    for (char d : "}])")
      if (c == d) dep--;
    for (char d : "+-*/%^<>=&|?,")
      if (c == d && !dep) return "(" + x + ")";
  }
  return x;
}
template <class T, class U>
pair<U, T> pinv(pair<T, U> x) {
  return make_pair(x.second, x.first);
}
template <class T>
struct Wt71 {
  T c;
  int l, r, L, R;
};
template <class T>
ostream &operator<<(ostream &o, Wt71<T> M) {
  o << "\n";
  for (int i = M.l; i <= (int)(M.r); i++) {
    o << "  " << i << ": | ";
    for (int j = M.L; j <= (int)(M.R); j++) {
      o << M.c[i][j] << ((j - M.L + 1) % 5 ? " " : "; ");
    }
    o << "\n";
  }
  return o;
}
template <class T>
Wt71<T> q9cX(T a, int i, int j, int k, int q) {
  return {a, i, j, k, q};
}
int primes[] = {2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,
                43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,
                103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
                173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
                241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,
                317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,
                401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467,
                479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569,
                571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643,
                647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
                739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823,
                827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,
                919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997},
    big_primes[] = {1307533217, 1336158883, 1339172111, 1367797777, 1376837461,
                    1399436671, 1426555723, 1440115249, 1444635091, 1489833511,
                    1553111299, 1562150983, 1587763421, 1610362631, 1652547823,
                    1666107349, 1700759471, 1782116627, 1797182767, 1810742293,
                    1818275363, 1892099449, 1904152361, 1919218501, 1940311097,
                    1944830939, 1968936763, 1977976447, 1985509517, 1990029359},
    gens[] = {1,   2,   3,   5,   2,   11,  3,   14,  19,  11,  17,  32,  30,
              34,  29,  19,  34,  31,  63,  33,  5,   63,  53,  58,  40,  83,
              21,  18,  99,  33,  106, 40,  85,  109, 40,  77,  91,  120, 105,
              91,  79,  53,  182, 10,  184, 48,  48,  150, 168, 72,  65,  46,
              31,  216, 101, 134, 163, 147, 93,  42,  69,  7,   151, 308, 112,
              12,  227, 185, 214, 305, 163, 234, 154, 316, 3,   11,  233, 390,
              271, 173, 82,  407, 13,  135, 414, 391, 177, 293, 426, 432, 337,
              281, 385, 103, 95,  152, 12,  371, 390, 77,  532, 34,  287, 73,
              308, 493, 258, 549, 528, 411, 12,  283, 614, 596, 622, 309, 91,
              511, 287, 433, 585, 123, 2,   170, 183, 341, 459, 322, 333, 337,
              507, 718, 82,  517, 396, 315, 565, 48,  362, 617, 776, 425, 584,
              231, 578, 395, 127, 27,  506, 435, 727, 659, 697, 385, 290, 109,
              430, 422, 344, 849, 513, 453, 852, 920, 152, 482, 653, 271},
    big_gens[] = {661761153,  1315209189, 235649158,  80905954,  861543922,
                  677870461,  332266749,  1192707557, 820697698, 93737534,
                  1395132003, 176849700,  1113502216, 860516128, 1543755630,
                  328298286,  1219407972, 1407392293, 733053145, 400000570,
                  1081174233, 847228024,  1516266762, 83276926,  500618997,
                  44975430,   47827763,   1411328206, 151880843, 19696955};
LL vbig_primes[] = {
    1223771071ULL,        2557943639LL,          4625922079LL,
    8465729693LL,         16196062793LL,         32628322457LL,
    64355194333LL,        128143942897LL,        256728067087LL,
    512368953949LL,       1024440714547LL,       2048302681847LL,
    4096121499499LL,      8192933500519LL,       16384652744209LL,
    32768255472209LL,     65536007832649LL,      131072225217863LL,
    262144391360893LL,    524288060819213LL,     1048576249040491ULL,
    2097152266756471ULL,  4194304028438527LL,    8388608209001387LL,
    16777216572671047LL,  33554432072300339LL,   67108864903274897LL,
    134217728402776373LL, 268435456069367221ULL, 536870912016065747LL};
const int inf = 1e9, NONE = -1;
const LL llinf = 3e18;
const char *sc2 = "%d%d", *sc3 = "%d%d%d", *sc4 = "%d%d%d%d", *pr2 = "%d %d\n",
           *pr3 = "%d %d %d\n", *pr4 = "%d %d %d %d\n";
VI factor(int x) {
  VI ans;
  for (int p = 2; p * p <= x; ++p)
    while (x % p == 0) {
      ans.push_back(p);
      x /= p;
    }
  if (x > 1) ans.push_back(x);
  return ans;
}
template <class T, class B, class C, class D>
auto operator+(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first + y.first), decltype(x.second + y.second)> {
  return make_pair(x.first + y.first, x.second + y.second);
}
template <class T, class B, class C>
auto operator+(pair<T, B> x, C y)
    -> pair<decltype(x.first + y), decltype(x.second + y)> {
  return make_pair(x.first + y, x.second + y);
}
template <class T, class C, class D>
auto operator+(T x, pair<C, D> y)
    -> pair<decltype(x + y.first), decltype(x + y.second)> {
  return make_pair(x + y.first, x + y.second);
}
template <class T, class B, class C, class D>
auto operator-(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first - y.first), decltype(x.second - y.second)> {
  return make_pair(x.first - y.first, x.second - y.second);
}
template <class T, class B, class C>
auto operator-(pair<T, B> x, C y)
    -> pair<decltype(x.first - y), decltype(x.second - y)> {
  return make_pair(x.first - y, x.second - y);
}
template <class T, class C, class D>
auto operator-(T x, pair<C, D> y)
    -> pair<decltype(x - y.first), decltype(x - y.second)> {
  return make_pair(x - y.first, x - y.second);
}
template <class T, class B, class C, class D>
auto operator/(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first / y.first), decltype(x.second / y.second)> {
  return make_pair(x.first / y.first, x.second / y.second);
}
template <class T, class B, class C>
auto operator/(pair<T, B> x, C y)
    -> pair<decltype(x.first / y), decltype(x.second / y)> {
  return make_pair(x.first / y, x.second / y);
}
template <class T, class C, class D>
auto operator/(T x, pair<C, D> y)
    -> pair<decltype(x / y.first), decltype(x / y.second)> {
  return make_pair(x / y.first, x / y.second);
}
template <class T, class B, class C, class D>
auto operator*(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first * y.first), decltype(x.second * y.second)> {
  return make_pair(x.first * y.first, x.second * y.second);
}
template <class T, class B, class C>
auto operator*(pair<T, B> x, C y)
    -> pair<decltype(x.first * y), decltype(x.second * y)> {
  return make_pair(x.first * y, x.second * y);
}
template <class T, class C, class D>
auto operator*(T x, pair<C, D> y)
    -> pair<decltype(x * y.first), decltype(x * y.second)> {
  return make_pair(x * y.first, x * y.second);
}
template <class T, class B, class C, class D>
auto operator%(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first % y.first), decltype(x.second % y.second)> {
  return make_pair(x.first % y.first, x.second % y.second);
}
template <class T, class B, class C>
auto operator%(pair<T, B> x, C y)
    -> pair<decltype(x.first % y), decltype(x.second % y)> {
  return make_pair(x.first % y, x.second % y);
}
template <class T, class C, class D>
auto operator%(T x, pair<C, D> y)
    -> pair<decltype(x % y.first), decltype(x % y.second)> {
  return make_pair(x % y.first, x % y.second);
}
template <class T, class B, class C, class D>
auto operator&(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first & y.first), decltype(x.second & y.second)> {
  return make_pair(x.first & y.first, x.second & y.second);
}
template <class T, class B, class C>
auto operator&(pair<T, B> x, C y)
    -> pair<decltype(x.first & y), decltype(x.second & y)> {
  return make_pair(x.first & y, x.second & y);
}
template <class T, class C, class D>
auto operator&(T x, pair<C, D> y)
    -> pair<decltype(x & y.first), decltype(x & y.second)> {
  return make_pair(x & y.first, x & y.second);
}
template <class T, class B, class C, class D>
auto operator|(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first | y.first), decltype(x.second | y.second)> {
  return make_pair(x.first | y.first, x.second | y.second);
}
template <class T, class B, class C>
auto operator|(pair<T, B> x, C y)
    -> pair<decltype(x.first | y), decltype(x.second | y)> {
  return make_pair(x.first | y, x.second | y);
}
template <class T, class C, class D>
auto operator|(T x, pair<C, D> y)
    -> pair<decltype(x | y.first), decltype(x | y.second)> {
  return make_pair(x | y.first, x | y.second);
}
template <class T, class B, class C, class D>
auto operator^(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first ^ y.first), decltype(x.second ^ y.second)> {
  return make_pair(x.first ^ y.first, x.second ^ y.second);
}
template <class T, class B, class C>
auto operator^(pair<T, B> x, C y)
    -> pair<decltype(x.first ^ y), decltype(x.second ^ y)> {
  return make_pair(x.first ^ y, x.second ^ y);
}
template <class T, class C, class D>
auto operator^(T x, pair<C, D> y)
    -> pair<decltype(x ^ y.first), decltype(x ^ y.second)> {
  return make_pair(x ^ y.first, x ^ y.second);
}
template <class T, class B, class C, class D>
auto operator&&(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first && y.first), decltype(x.second && y.second)> {
  return make_pair(x.first && y.first, x.second && y.second);
}
template <class T, class B, class C>
auto operator&&(pair<T, B> x, C y)
    -> pair<decltype(x.first && y), decltype(x.second && y)> {
  return make_pair(x.first && y, x.second && y);
}
template <class T, class C, class D>
auto operator&&(T x, pair<C, D> y)
    -> pair<decltype(x && y.first), decltype(x && y.second)> {
  return make_pair(x && y.first, x && y.second);
}
template <class T, class B, class C, class D>
auto operator||(pair<T, B> x, pair<C, D> y)
    -> pair<decltype(x.first || y.first), decltype(x.second || y.second)> {
  return make_pair(x.first || y.first, x.second || y.second);
}
template <class T, class B, class C>
auto operator||(pair<T, B> x, C y)
    -> pair<decltype(x.first || y), decltype(x.second || y)> {
  return make_pair(x.first || y, x.second || y);
}
template <class T, class C, class D>
auto operator||(T x, pair<C, D> y)
    -> pair<decltype(x || y.first), decltype(x || y.second)> {
  return make_pair(x || y.first, x || y.second);
}
template <class T, class B>
pair<T, B> &operator++(pair<T, B> &x) {
  ++x.first, ++x.second;
  return x;
}
template <class T, class B>
pair<T, B> operator++(pair<T, B> &x, int _) {
  return make_pair(x.first++, x.second++);
}
template <class T, class B>
pair<T, B> &operator--(pair<T, B> &x) {
  --x.first, --x.second;
  return x;
}
template <class T, class B>
pair<T, B> operator--(pair<T, B> &x, int _) {
  return make_pair(x.first--, x.second--);
}
template <class T, class B, class C, class D>
pair<T, B> &operator+=(pair<T, B> &x, pair<C, D> y) {
  x.first += y.first;
  x.second += y.second;
  return x;
}
template <class T, class B, class C>
pair<T, B> &operator+=(pair<T, B> &x, C y) {
  x.first += y;
  x.second += y;
  return x;
}
template <class T, class B, class C, class D>
pair<T, B> &operator-=(pair<T, B> &x, pair<C, D> y) {
  x.first -= y.first;
  x.second -= y.second;
  return x;
}
template <class T, class B, class C>
pair<T, B> &operator-=(pair<T, B> &x, C y) {
  x.first -= y;
  x.second -= y;
  return x;
}
template <class T, class B, class C, class D>
pair<T, B> &operator*=(pair<T, B> &x, pair<C, D> y) {
  x.first *= y.first;
  x.second *= y.second;
  return x;
}
template <class T, class B, class C>
pair<T, B> &operator*=(pair<T, B> &x, C y) {
  x.first *= y;
  x.second *= y;
  return x;
}
template <class T, class B, class C, class D>
pair<T, B> &operator/=(pair<T, B> &x, pair<C, D> y) {
  x.first /= y.first;
  x.second /= y.second;
  return x;
}
template <class T, class B, class C>
pair<T, B> &operator/=(pair<T, B> &x, C y) {
  x.first /= y;
  x.second /= y;
  return x;
}
template <class T, class B, class C, class D>
pair<T, B> &operator%=(pair<T, B> &x, pair<C, D> y) {
  x.first %= y.first;
  x.second %= y.second;
  return x;
}
template <class T, class B, class C>
pair<T, B> &operator%=(pair<T, B> &x, C y) {
  x.first %= y;
  x.second %= y;
  return x;
}
template <class T, class B, class C, class D>
pair<T, B> &operator^=(pair<T, B> &x, pair<C, D> y) {
  x.first ^= y.first;
  x.second ^= y.second;
  return x;
}
template <class T, class B, class C>
pair<T, B> &operator^=(pair<T, B> &x, C y) {
  x.first ^= y;
  x.second ^= y;
  return x;
}
template <class T, class B, class C, class D>
pair<T, B> &operator&=(pair<T, B> &x, pair<C, D> y) {
  x.first &= y.first;
  x.second &= y.second;
  return x;
}
template <class T, class B, class C>
pair<T, B> &operator&=(pair<T, B> &x, C y) {
  x.first &= y;
  x.second &= y;
  return x;
}
template <class T, class B, class C, class D>
pair<T, B> &operator|=(pair<T, B> &x, pair<C, D> y) {
  x.first |= y.first;
  x.second |= y.second;
  return x;
}
template <class T, class B, class C>
pair<T, B> &operator|=(pair<T, B> &x, C y) {
  x.first |= y;
  x.second |= y;
  return x;
}
template <class T, class B>
auto operator*(pair<T, B> x)
    -> pair<typename remove_reference<decltype(*x.first)>::type,
            typename remove_reference<decltype(*x.second)>::type> {
  return make_pair(*x.first, *x.second);
}
template <class T, class B>
auto operator~(pair<T, B> x)
    -> pair<typename remove_reference<decltype(~x.first)>::type,
            typename remove_reference<decltype(~x.second)>::type> {
  return make_pair(~x.first, ~x.second);
}
template <class T, class B>
auto operator!(pair<T, B> x)
    -> pair<typename remove_reference<decltype(!x.first)>::type,
            typename remove_reference<decltype(!x.second)>::type> {
  return make_pair(!x.first, !x.second);
}
template <class T, class B>
auto operator-(pair<T, B> x)
    -> pair<typename remove_reference<decltype(-x.first)>::type,
            typename remove_reference<decltype(-x.second)>::type> {
  return make_pair(-x.first, -x.second);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, zet_p>::type operator+(zet_p x,
                                                                   T y) {
  return x + zet_p(y);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, zet_p>::type operator+(T x,
                                                                   zet_p y) {
  return zet_p(x) + y;
}
template <class T>
zet_p &operator+=(zet_p &x, T y) {
  return x = x + y;
}
template <class T>
typename enable_if<is_arithmetic<T>::value, zet_p>::type operator-(zet_p x,
                                                                   T y) {
  return x - zet_p(y);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, zet_p>::type operator-(T x,
                                                                   zet_p y) {
  return zet_p(x) - y;
}
template <class T>
zet_p &operator-=(zet_p &x, T y) {
  return x = x - y;
}
template <class T>
typename enable_if<is_arithmetic<T>::value, zet_p>::type operator*(zet_p x,
                                                                   T y) {
  return x * zet_p(y);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, zet_p>::type operator*(T x,
                                                                   zet_p y) {
  return zet_p(x) * y;
}
template <class T>
zet_p &operator*=(zet_p &x, T y) {
  return x = x * y;
}
template <class T>
typename enable_if<is_arithmetic<T>::value, zet_p>::type operator/(zet_p x,
                                                                   T y) {
  return x / zet_p(y);
}
template <class T>
typename enable_if<is_arithmetic<T>::value, zet_p>::type operator/(T x,
                                                                   zet_p y) {
  return zet_p(x) / y;
}
template <class T>
zet_p &operator/=(zet_p &x, T y) {
  return x = x / y;
}
void jGB4A();
const int MN = 1e6 + 44;
const int ML = 61;
ULL shift[ML];
PULL coo(ULL x) {
  int layer = 64 - clz(x);
  ;
  ;
  return make_pair(layer, (x - (1ULL << (layer - 1)) - shift[layer]) &
                              ((1ULL << (layer - 1)) - 1));
}
ULL curr_nr(PULL x) {
  return (1ULL << (x.first - 1)) +
         ((x.second + shift[x.first]) & ((1ULL << (x.first - 1)) - 1));
}
PULL up(PULL x) { return make_pair(x.first - 1, x.second / 2); }
int main() {
  ;
  ;
  ;
  ;
  ;
  cerr << setprecision(10);
  int q;
  scanf("%d", &q);
  for (int _ = 0; _ < (int)(q); _++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      ULL x;
      LL k;
      scanf("%llu%lld", &x, &k);
      assert(curr_nr(coo(x)) == x);
      int l = coo(x).first;
      ;
      shift[l] -= k;
    } else if (t == 2) {
      ULL x, k;
      scanf("%llu%llu", &x, &k);
      assert(curr_nr(coo(x)) == x);
      int l = coo(x).first;
      for (int i = l; i <= (int)(ML - 1); i++) {
        shift[i] -= k;
        ;
        k *= 2;
      };
    } else {
      ULL x;
      scanf("%llu", &x);
      assert(curr_nr(coo(x)) == x);
      PULL where = coo(x);
      do {
        ;
        assert(coo(curr_nr(where)) == where);
        printf("%llu ", curr_nr(where));
        where = up(where);
      } while (where.first);
      printf("\n");
    };
  }
  jGB4A();
}
void jGB4A() {
#pragma GCC diagnostic ignored "-Woverflow"
  ;
  ;
  ;
  ;
  ;
  ;
  ;
  ;
  ;
  ;
  while (deb && getchar() != EOF)
    ;
  exit(0);
}