As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires.

Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be respected by warriors.

Each warrior is represented by his personality — an integer number pi. Each commander has two characteristics — his personality pj and leadership lj (both are integer numbers). Warrior i respects commander j only if <image> (<image> is the bitwise excluding OR of x and y).

Initially Vova's army is empty. There are three different types of events that can happen with the army:

  * 1 pi — one warrior with personality pi joins Vova's army; 
  * 2 pi — one warrior with personality pi leaves Vova's army; 
  * 3 pi li — Vova tries to hire a commander with personality pi and leadership li. 



For each event of the third type Vova wants to know how many warriors (counting only those who joined the army and haven't left yet) respect the commander he tries to hire.

Input

The first line contains one integer q (1 ≤ q ≤ 100000) — the number of events.

Then q lines follow. Each line describes the event:

  * 1 pi (1 ≤ pi ≤ 108) — one warrior with personality pi joins Vova's army; 
  * 2 pi (1 ≤ pi ≤ 108) — one warrior with personality pi leaves Vova's army (it is guaranteed that there is at least one such warrior in Vova's army by this moment); 
  * 3 pi li (1 ≤ pi, li ≤ 108) — Vova tries to hire a commander with personality pi and leadership li. There is at least one event of this type. 

Output

For each event of the third type print one integer — the number of warriors who respect the commander Vova tries to hire in the event.

Example

Input

5
1 3
1 4
3 6 3
2 4
3 6 3


Output

1
0

Note

In the example the army consists of two warriors with personalities 3 and 4 after first two events. Then Vova tries to hire a commander with personality 6 and leadership 3, and only one warrior respects him (<image>, and 2 < 3, but <image>, and 5 ≥ 3). Then warrior with personality 4 leaves, and when Vova tries to hire that commander again, there are no warriors who respect him.
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using int64 = long long int;
template <typename T>
void chmax(T& a, T b) {
  a = max(a, b);
}
template <typename T>
void chmin(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void chadd(T& a, T b) {
  a = a + b;
}
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
template <typename Type = unsigned int, int B = 32>
struct BinaryTrie {
 private:
  struct Node {
    int cnt;
    Type lazy;
    Node* child[2];
    Node() : cnt(0), lazy(0), child{nullptr, nullptr} {}
  };
  int get_size(Node* t) const { return t ? t->cnt : 0; }
  void lazy_eval(Node* t, int b) const {
    if ((t->lazy >> (Type)b) & (Type)1) swap(t->child[0], t->child[1]);
    if (t->child[0]) t->child[0]->lazy ^= t->lazy;
    if (t->child[1]) t->child[1]->lazy ^= t->lazy;
    t->lazy = 0;
  }
  Node* add(Node* t, Type val, int b = B - 1) {
    if (!t) t = new Node;
    t->cnt++;
    if (b < 0) return t;
    lazy_eval(t, b);
    int bin = (val >> (Type)b) & (Type)1;
    t->child[bin] = add(t->child[bin], val, b - 1);
    return t;
  }
  Node* sub(Node* t, Type val, int b = B - 1) {
    assert(t);
    t->cnt--;
    if (t->cnt == 0) return nullptr;
    if (b < 0) return t;
    lazy_eval(t, b);
    int bin = (val >> (Type)b) & (Type)1;
    t->child[bin] = sub(t->child[bin], val, b - 1);
    return t;
  }
  Type get_min(Node* t, Type val, int b = B - 1) const {
    assert(t);
    if (b < 0) return 0;
    lazy_eval(t, b);
    int bin = (val >> (Type)b) & (Type)1;
    bin ^= !t->child[bin];
    return get_min(t->child[bin], val, b - 1) | ((Type)bin << (Type)b);
  }
  Type get_kth(Node* t, Type val, int k, int b = B - 1) const {
    assert(t);
    if (b < 0) return 0;
    lazy_eval(t, b);
    int bin = (val >> (Type)b) & (Type)1;
    if (get_size(t->child[bin]) < k) k -= get_size(t->child[bin]), bin ^= 1;
    return get_kth(t->child[bin], val, k, b - 1) | ((Type)bin << (Type)b);
  }
  int get_lower(Node* t, Type val, int b = B - 1) {
    if (!t || b < 0) return 0;
    lazy_eval(t, b);
    bool bin = (val >> (Type)b) & (Type)1;
    return (bin && t->child[0] ? t->child[0]->cnt : 0) +
           get_lower(t->child[bin], val, b - 1);
  }
  int count_less(Node* t, Type val, Type x, int b = B - 1) {
    if (!t || b < 0) return 0;
    lazy_eval(t, b);
    bool bin = (val >> (Type)b) & (Type)1;
    int add = 0;
    if (x >> (Type)b & 1) add += get_size(t->child[bin]), bin ^= 1;
    return add + count_less(t->child[bin], val, x, b - 1);
  }
  Node* root;

 public:
  BinaryTrie() : root(nullptr) {}
  int size() const { return get_size(root); }
  bool empty() const { return !root; }
  void insert(Type val) { root = add(root, val); }
  void erase(Type val) { root = sub(root, val); }
  Type max_element(Type XOR = 0) const { return get_min(root, ~XOR); }
  Type min_element(Type XOR = 0) const { return get_min(root, XOR); }
  void xor_all(Type val) {
    if (root) root->lazy ^= val;
  }
  int lower_bound(Type val) { return get_lower(root, val); }
  int upper_bound(Type val) { return get_lower(root, val + 1); }
  int count_less(Type val, Type XOR = 0) { return count_less(root, XOR, val); }
  int count_upper(Type val, Type XOR = 0) {
    return size() - count_less(root, XOR, val + 1);
  }
  Type get_kth(int k, Type XOR = 0) const {
    assert(0 <= k and k < size());
    return get_kth(root, XOR, k + 1);
  }
  Type operator[](int k) { return get_kth(k); }
};
int main() {
  int Q;
  scanf("%d", &Q);
  BinaryTrie<> bt;
  while (Q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int v;
      scanf("%d", &v);
      bt.insert(v);
    }
    if (t == 2) {
      int v;
      scanf("%d", &v);
      bt.erase(v);
    }
    if (t == 3) {
      int p, l;
      scanf("%d%d", &p, &l);
      printf("%d\n", bt.count_less(l, p));
    }
  }
  return 0;
}
