#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
const long long maxn = 2e5 + 5;
long long shift[100];
long long numberOfNodes[100];
long long findLevel(long long x) {
  long long ans = 0;
  for (long long i = 62; i >= 0; i--) {
    long long curr = 1ll << i;
    if (curr & x) {
      ans = i + 1;
      break;
    }
  }
  return ans;
}
void f() {
  long long t;
  cin >> t;
  if (t == 1) {
    long long x, k;
    cin >> x >> k;
    long long temp = findLevel(x);
    shift[temp] = (shift[temp] + k) % (numberOfNodes[temp]);
    if (shift[temp] < 0) shift[temp] += numberOfNodes[temp];
  } else if (t == 2) {
    long long x, k;
    cin >> x >> k;
    long long temp = findLevel(x);
    for (long long i = temp; i <= 61; i++) {
      shift[i] = (shift[i] + k) % (numberOfNodes[i]);
      if (shift[i] < 0) shift[i] += numberOfNodes[i];
      k %= numberOfNodes[i];
      if (k < 0) k += numberOfNodes[i];
      k *= 2;
    }
  } else {
    long long x;
    cin >> x;
    long long temp = findLevel(x);
    cout << x << " ";
    ;
    x += shift[temp];
    while (x >= 2 * numberOfNodes[temp]) x -= numberOfNodes[temp];
    x /= 2;
    long long index = x;
    for (long long i = temp - 1; i >= 1; i--) {
      x = index;
      x -= shift[i];
      while (x < numberOfNodes[i]) x += numberOfNodes[i];
      cout << x << " ";
      ;
      index /= 2;
    }
    cout << "" << endl;
    ;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  ;
  for (long long i = 1; i < 62; ++i) {
    numberOfNodes[i] = (1ll << (i - 1));
  }
  long long q;
  cin >> q;
  while (q--) {
    f();
  }
  return 0;
}
