#include <bits/stdc++.h>
using namespace std;
map<long long, long long> Q1, Q2;
long long newPos(long long pos, long long shift, long long lvlPow2) {
  lvlPow2 /= 2;
  if (lvlPow2 == 1) return 1;
  shift %= lvlPow2;
  if (0 > shift) shift += lvlPow2;
  if (pos - lvlPow2 - shift >= 0) {
    return (pos - shift);
  } else {
    return pos + lvlPow2 - shift;
  }
}
long long orginPos(long long pos, long long shift, long long lvlPow2) {
  lvlPow2 /= 2;
  if (lvlPow2 == 1) return 1;
  shift %= lvlPow2;
  return (pos + shift) % lvlPow2 + lvlPow2;
}
void Q3(long long node) {
  printf("%lld ", node);
  long long lvl, lvlPow2, shift;
  lvl = log2(node) + 1, lvlPow2 = 1ll << lvl;
  long long pos = orginPos(node, Q1[lvl] + Q2[lvl], lvlPow2) / 2;
  while (pos) {
    lvl--, lvlPow2 /= 2, shift = Q1[lvl];
    printf("%lld ", newPos(pos, shift, lvlPow2));
    pos = orginPos(pos, Q2[lvl], lvlPow2) / 2;
  }
  puts("");
}
int main() {
  int n, QType;
  long long a, b;
  cin >> n;
  while (n--) {
    scanf("%d", &QType);
    if (QType == 1) {
      scanf("%lld%lld", &a, &b);
      if (a == 1) continue;
      a = log2(a) + 1;
      Q1[a] += b;
    } else if (QType == 2) {
      scanf("%lld%lld", &a, &b);
      a = log2(a) + 1;
      Q2[a] += b;
    } else {
      scanf("%lld", &a);
      Q3(a);
    }
  }
  return 0;
}
