#include <bits/stdc++.h>
using namespace std;
int q;
long long k1[66], k2[66];
long long LOG[66];
long long get(long long x) {
  int l = 0, r = 60;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (x >= LOG[mid])
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
void go(long long x, int v) {
  printf("%I64d ", x);
  if (!v) return;
  x -= LOG[v];
  x = (x + k1[v] + k2[v]) & (LOG[v] - 1);
  x += LOG[v];
  x = x / 2 - LOG[v - 1];
  x = (x + LOG[v - 1] - k1[v - 1]) & (LOG[v - 1] - 1);
  x += LOG[v - 1];
  go(x, v - 1);
}
void solve() {
  int t;
  scanf("%d", &t);
  if (t < 3) {
    long long x, k;
    scanf("%I64d%I64d", &x, &k);
    long long v = get(x), sum = (1ll << v);
    k %= sum;
    if (t == 1)
      k1[v] = (sum + k1[v] + k) & (sum - 1);
    else
      k2[v] = (sum + k2[v] + k) & (sum - 1);
  } else if (t == 3) {
    long long x;
    scanf("%I64d", &x);
    long long v = get(x);
    go(x, v);
    printf("\n");
  }
}
int main() {
  cin >> q;
  LOG[0] = 1;
  for (int i = 1; i <= 60; ++i) LOG[i] = LOG[i - 1] * 2;
  while (q--) solve();
  return 0;
}
