#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  long long s1[60] = {};
  long long s2[60] = {};
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    long long x;
    cin >> x;
    int level = log2(x);
    long long m = 1LL << level;
    if (t == 3) {
      long long pos = x - m;
      long long shift = s1[level];
      for (int i = 0; i <= level; ++i) {
        shift += s2[i] * (1LL << (level - i));
      }
      shift %= m;
      pos = (pos + shift) % m;
      cout << fixed << x << " ";
      for (int i = level - 1; i >= 0; --i) {
        pos /= 2;
        m >>= 1;
        shift = s1[i];
        for (int j = 0; j <= i; ++j) {
          shift += s2[j] * (1LL << (i - j));
        }
        shift %= m;
        long long val = (pos - shift + m) % m + m;
        cout << fixed << val << " ";
      }
      cout << endl;
    } else {
      long long k;
      cin >> k;
      if (t == 1) {
        s1[level] = (((s1[level] + k) % m) + m) % m;
      } else {
        s2[level] = (((s2[level] + k) % m) + m) % m;
      }
    }
  }
  return 0;
}
