#include <bits/stdc++.h>
using namespace std;
long long cyc[110];
int main() {
  long long t, i, j, k, l, n, m, q, e = 1;
  string str;
  long long k1, k2;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> m;
  long long x;
  while (m--) {
    cin >> t;
    if (t <= 2) {
      cin >> x >> k;
      long long level = 0, j = 1, op = 0;
      while (level < x) {
        level += j;
        j *= 2;
        op++;
      }
      j /= 2;
      k %= j;
      if (k < 0) k += j;
      if (t == 1)
        cyc[op] += k, cyc[op] %= j;
      else {
        long long jj = k;
        for (i = op; i <= 60; i++) {
          cyc[i] += jj, jj *= 2, cyc[i] %= j, j *= 2;
        }
      }
    } else {
      cin >> x;
      long long level = 0, j = 1, op = 0;
      while (level < x) {
        level += j;
        j *= 2;
        op++;
      }
      j /= 2;
      long long op2 = x - (level - j);
      op2 = op2 + (cyc[op]);
      if (op2 > j) op2 -= j;
      cout << x << ' ';
      op2 += level - j;
      level -= j;
      while (op > 1) {
        op--;
        op2 /= 2;
        j /= 2;
        long long op3 = op2;
        op2 = op3 - (level - j) - cyc[op];
        if (op2 <= 0) op2 += j;
        op2 += level - j;
        cout << op2 << ' ';
        level -= j;
        op2 = op3;
      }
      cout << '\n';
    }
  }
  return 0;
}
