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.
import java.io.*;
import java.util.*;

public class Main{
	static int alpha=2;
	static int maxSize=(int)3e6 + 1;
	static int lastTrieNode;
	static int[][]next;
	static int[]subTree;
	
	static int makeNode() {
		int idx=lastTrieNode++;
		next[idx]=new int[alpha];
		return idx;
	}
	
	static void insert(int prev,int i,int toInsert)
	{
		int bit=((toInsert>>i)&1);
		
		int cur = next[prev][bit];
		if(cur == 0) {
			int idx=makeNode();
			cur = next[prev][bit] = idx;
		}
		if(i==0) {
			subTree[cur]++;
			return;
		}
		insert(cur, i-1, toInsert);
		int nxt0=next[cur][0],nxt1=next[cur][1];
		subTree[cur]=(subTree[nxt0]+subTree[nxt1]);
	}
	static void remove(int prev,int i,int toRemove)
	{
		int bit=((toRemove>>i)&1);
		
		int cur = next[prev][bit];
//		if(cur == 0) {
//			int idx=makeNode();
//			cur = next[prev][bit] = idx;
//		}
		if(i==0) {
			subTree[cur]--;
			return;
		}
		remove(cur, i-1, toRemove);
		int nxt0=next[cur][0],nxt1=next[cur][1];
		subTree[cur]=(subTree[nxt0]+subTree[nxt1]);
	}
	static int cntGreaterOrEqualK(int xor,int k) {
		int prev=0;
		int ans=0;
		for(int i=28;i>=0;i--) {
			int bitXOR=((xor>>i)&1);
			int bitK=((k>>i)&1);
			
			int []nxt=new int[] {next[prev][0],next[prev][1]};
			int take=bitXOR^1;
			if(bitK==0) {
				ans+=subTree[nxt[take]];
				prev=nxt[take^1];
			}
			else {
				prev=nxt[take];
			}
			if(prev==0) {
				break;
			}
		}
		ans+=subTree[prev];
		return ans;
	}
   	static void main() throws Exception{
   		next=new int[maxSize][];
		subTree=new int[maxSize];
		makeNode();//root
		int q=sc.nextInt();
		int inserted=0;
		while(q-->0) {
			int cmd=sc.nextInt(),p=sc.nextInt();
			if(cmd==1) {
				insert(0, 28, p);
				inserted++;
			}
			else {
				if(cmd==2) {
					remove(0, 28, p);
					inserted--;
				}
				else {
					int l=sc.nextInt();
					pw.println(inserted-cntGreaterOrEqualK(p, l));
				}
			}
		}
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
		while(tc-->0)main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}
