#include <bits/stdc++.h>
using namespace std;
map<long long, long long> q1, q2;
pair<int, long long> conv(long long x) {
  int lvl = 0;
  long long mod = 1;
  while (x) {
    lvl++;
    x >>= 1;
    mod <<= 1;
  }
  return make_pair(lvl, mod / 2);
}
long long calc(long long x, long long mod, int lvl) {
  long long tmp = 0;
  if (q1.count(lvl)) {
    tmp += q1[lvl] + mod;
  }
  if (q2.count(lvl)) {
    tmp += q2[lvl] + mod;
  }
  return (x + tmp) % mod;
}
void solution() {
  int q;
  cin >> q;
  while (q--) {
    int t;
    long long x, k;
    scanf("%d%I64d", &t, &x);
    pair<int, long long> tmp = conv(x);
    int lvl = tmp.first;
    long long mod = tmp.second;
    if (t == 1) {
      scanf("%I64d", &k);
      q1[lvl] = (q1[lvl] + k) % mod;
    } else if (t == 2) {
      scanf("%I64d", &k);
      q2[lvl] = (q2[lvl] + k) % mod;
    } else {
      while (x > 1) {
        printf("%I64d ", x);
        long long pos = mod + calc(x, mod, lvl);
        x = (pos >> 1);
        mod >>= 1;
        lvl--;
        if (q1.count(lvl)) {
          x = mod + (x + mod - q1[lvl]) % mod;
        }
      }
      printf("1\n");
    }
  }
}
int main() { solution(); }
