#include <bits/stdc++.h>
using namespace std;
long long nodeS[70], valueS[70];
long long po[70];
int getL(long long x) {
  int lvl = 1;
  while (x != 1) {
    x /= 2;
    lvl++;
  }
  return lvl;
}
int main() {
  po[1] = 1;
  for (int i = 2; i < 65; i++) {
    po[i] = po[i - 1] * 2;
  }
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int t;
    long long x, k;
    scanf("%d %lld", &t, &x);
    if (t == 1) {
      scanf("%lld", &k);
      int level = getL(x);
      valueS[level] = (valueS[level] + (k % po[level]) + po[level]) % po[level];
    } else if (t == 2) {
      scanf("%lld", &k);
      int level = getL(x);
      nodeS[level] = (nodeS[level] + (k % po[level]) + po[level]) % po[level];
    } else {
      vector<long long> ans;
      long long cum = 0;
      long long mult = 2;
      int level = 1;
      stack<long long> st;
      while (mult <= x) {
        cum = (cum * 2) % po[level];
        cum += nodeS[level];
        st.push(cum + valueS[level]);
        level++;
        mult *= 2;
      }
      st.push((cum * 2 + valueS[level] + nodeS[level]) % po[level]);
      long long node =
          (x - po[level] + (st.top() % po[level]) + po[level]) % po[level] +
          po[level];
      if (node != 1) {
        ans.push_back(x);
        st.pop();
        node /= 2;
        level--;
      }
      while (node != 1) {
        long long back = st.top();
        st.pop();
        long long valueA =
            (node - po[level] - (back % po[level]) + po[level]) % po[level] +
            po[level];
        ans.push_back(valueA);
        node /= 2;
        level--;
      }
      ans.push_back(node);
      for (int i = 0; i < (int)ans.size(); i++) {
        printf("%lld ", ans[i]);
      }
      printf("\n");
    }
  }
  return 0;
}
