#include <bits/stdc++.h>
using namespace std;
const int maxk = 64;
const int maxn = 1e5 + 17;
int Q;
long long size[maxk];
long long offset[maxk];
inline void shift(int level, long long &x) {
  if (x < 0) x = size[level] - abs(x) % size[level];
  offset[level] = (offset[level] + (x %= size[level])) % size[level];
}
inline void getValue(int level, long long where) {
  printf("%lld ",
         (size[level] - offset[level] + where) % size[level] + size[level]);
  if (!level) printf("\n");
}
int main() {
  for (int i = 0; i < maxk; i++) size[i] = 1LL << i;
  scanf("%d", &Q);
  while (Q--) {
    int t;
    long long x, k;
    scanf("%d %lld", &t, &x);
    if (t == 1 || t == 2) scanf("%lld", &k);
    int level = 8 * sizeof(long long) - __builtin_clzll(x) - 1;
    if (t == 1) shift(level, k);
    if (t == 2)
      for (int i = level; i < maxk; i++) shift(i, k), k <<= 1;
    if (t == 3) {
      long long idx = (x - size[level] + offset[level]) % size[level];
      while (level >= 0) {
        getValue(level, idx);
        level--;
        idx >>= 1;
      }
    }
  }
  return 0;
}
